package cn.fl.project.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysUsrApiService;
import cmm.user.facade.system.condition.SysUsrQueryCondition;
import cmm.user.facade.system.dto.SysUsrDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.capital.condition.CapChnOvdRateQC;
import cn.fl.capital.dto.CapChnOvdRateDTO;
import cn.fl.capital.service.ICapChnOvdRateApiService;
import cn.fl.commons.result.ResponseData;
import cn.fl.deviceinfo.api.IDeviceInfoApiService;
import cn.fl.framework.base.constant.WebBaseConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.mcr.api.VinUtilsApiService;
import cn.fl.preloan.IPrjPrdDtlGpsApiService;
import cn.fl.preloan.IPrjPrdInvoiceApiService;
import cn.fl.preloan.condition.PrjPrdDtlGpsQueryCondition;
import cn.fl.preloan.condition.PrjPrdInvoiceQueryCondition;
import cn.fl.preloan.dto.PrjPrdInvoiceDTO;
import cn.fl.preloan.dto.gps.GpsDeviceDTO;
import cn.fl.prjprddtlgps.service.IPrjPrdDtlGpsService;
import cn.fl.prjprddtlgps.vo.PrjPrdDtlGpsVO;
import cn.fl.project.api.IPrjPrdDtlExtApiService;
import cn.fl.project.api.IPrjPrdExtApiService;
import cn.fl.project.condition.PrjPrdBscInfoQueryCondition;
import cn.fl.project.condition.PrjPrdDtlQueryCondition;
import cn.fl.project.condition.PrjQuatPrpsQueryCondition;
import cn.fl.project.constant.CarStyleConstant;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjPrdDtlConstant;
import cn.fl.project.constant.PrjQuatPrpsConstant;
import cn.fl.project.dto.PrjBscInfoDTO;
import cn.fl.project.dto.PrjPrdDtlExtDTO;
import cn.fl.project.dto.PrjPrdExtDTO;
import cn.fl.project.dto.PrjPrdSourceInfoDTO;
import cn.fl.project.service.*;
import cn.fl.project.transform.PrjPrdLicInfoVOTransform;
import cn.fl.project.utils.ValisityUtils;
import cn.fl.project.vo.*;
import cn.fl.system.constant.SysLogConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cvm.store.facade.cvm.api.IVechileStyleApiService;
import cvm.store.facade.cvm.dto.VechileStyleDTO;
import fl.riskctrl.facade.riskctrl.dto.RcCstBscInfoDTO;
import fl.riskctrl.facade.riskctrl.rccstchannelinfo.dto.RcCstChannelInfoDTO;
import fl.spl.facade.spl.api.ISplHRiskWarnRecApiService;
import fl.spl.facade.spl.condition.SplHRiskWarnRecQC;
import fl.spl.facade.spl.dto.SplHRiskWarnRecDTO;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;


/**
 * @Description: 项目产品明细信息表 控制层
 */
@Controller
@RequestMapping("/project/prjprddtl")
public class PrjPrdDtlController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(PrjPrdDtlController.class);

	/**
	 * PrjPrdDtl 服务层BEAN
	 */
	@Autowired
	private IPrjPrdDtlService prjPrdDtlService;
	@Autowired
	private IPrjPrdDtlExtApiService prjPrdDtlExtApiService;
	@Autowired
	private IPrjPrdBscInfoService prjPrdBscInfoService;//
	@Autowired
	private IProjectApiService projectApiService;	

	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	@Autowired
	private IPrjQuatPrpsService prjQuatPrpsService;
	@Autowired
	private IPrjPrdDtlGpsService prjPrdDtlGpsService;

	@Autowired
	private IPrjPrdLicInfoService prjPrdLicInfoService;

	@Autowired
	private VinUtilsApiService vinUtilsApiService;

	@Autowired
	private IPrjPrdVehInfoService prjPrdVehInfoService;

	@Autowired
	private ISplHRiskWarnRecApiService splHRiskWarnRecApiService;

	@Autowired
	private ICapChnOvdRateApiService capChnOvdRateApiService;

	@Autowired
	private IPrjPaySchMYqService prjPaySchMYqService;

	@Autowired
	private IPrjLnkCompService prjLnkCompService;

	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;

	@Autowired
	IDeviceInfoApiService deviceInfoApiService;

	@Autowired
	IPrjPrdInvoiceApiService prjPrdInvoiceApiService;

	@Autowired
	private IPrjPrdExtApiService prjPrdExtApiService;

	/**
	 * 车型查询
	 */
	@Autowired
	IVechileStyleApiService styleApiService;

	/**
	 * 系统用户
	 */
	@Autowired
	private ISysUsrApiService sysUsrApiService;

	@Autowired
	private IPrjPrdDtlGpsApiService prjPrdDtlGpsApiService;

	/**
	 * 到车辆信息修改页面(乘用车)
	 */
	@RequestMapping(value = "/toModifyPrjPrdDtlCarPrdInfoPage.do", method = { RequestMethod.GET})
	public ModelAndView toPrjPrdDtlCarPage(HttpServletRequest request, HttpServletResponse response) {
		String detailFlag = request.getParameter("detailFlag");
		String dtlId = request.getParameter("dtlId");
		//查找dtlid
		String isMust = request.getParameter("isMust");
		String prdTypCd = request.getParameter("prdTypCd");//产品分类
		String Caralter = request.getParameter("Caralter");//
		String ZCdetail = request.getParameter("ZCdetail");//仅用来控制专车
		String taskDefKey = request.getParameter("taskDefKey");//商助GPS审核节点
		
		int projectApproval = 0;//控制立项修改车辆显示的字段
		ModelAndView view = new ModelAndView("project/prjprddtl/projectPrdDtlCarInfoAdd");
		//产品分类不存在根据产品明细ID查询
		PrjPrdDtlVO dtlVO = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));
		view.addObject("dtlVO",dtlVO);
		PrjPrdBscInfoVO prjPrd = this.prjPrdBscInfoService.selectById(dtlVO.getPrjPrdId());
		view.addObject("prjPrd",prjPrd);
		if(StringUtils.isEmpty(prdTypCd)){
			prdTypCd = prjPrd.getPrdTypCd()==null?"":prjPrd.getPrdTypCd();
		}

		// 获取GPS卡号
		PrjPrdDtlGpsQueryCondition gpsQC = new PrjPrdDtlGpsQueryCondition();
		gpsQC.setPrjDtlId(Long.valueOf(dtlId));
		List<PrjPrdDtlGpsVO> gpsVOList = this.prjPrdDtlGpsService.searchList(gpsQC);
		if (CollectionUtils.isNotEmpty(gpsVOList)) {
			for (PrjPrdDtlGpsVO vo : gpsVOList) {
				if (null != vo.getSerialNo()) {
					if (vo.getSerialNo() == 1) {
						dtlVO.setGpsCardNo((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));

					} else if (vo.getSerialNo() == 2) {
						dtlVO.setGpsCardNo2((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr2((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd2((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));

					} else if (vo.getSerialNo() == 3) {
						dtlVO.setGpsCardNo3((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr3((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd3((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));
					}
				}

			}
		}

		// 获取车牌号
		PrjPrdLicInfoVO licInfoVO = this.prjPrdLicInfoService.selectById(Long.valueOf(dtlId));
		dtlVO.setVehNo("");
		if (licInfoVO != null){
			dtlVO.setVehNo((licInfoVO.getVehNo() == null)?"":licInfoVO.getVehNo());
		}
		BaseLogUtils.info(logger, "toModifyPrjPrdDtlCarPrdInfoPage", "获取到的车牌号："+JSON.toJSONString(dtlVO), CurrentThreadContext.getCurrentUserName());

		//厂商
		List<KeyValueVO> gpsNmList = this.prjBscInfoService.getGpsNmList();
		//厂商类型
		List<KeyValueVO> gpsTypList = this.prjBscInfoService.getGpsTypList();
		
	    //乘用车明细表
	   // PrdCarInfoVO cvo = this.prdCarInfoService.selectById(dtlVO.getPrdDtlId());//根据PrdDtlId查询乘用车明细
	    PrjPrdDtlExtDTO cvo = this.prjPrdDtlExtApiService.selectById(dtlVO.getPrjPrdId());//根据PrdDtlId查询乘用车明细
		BaseLogUtils.info(logger, "toListPage", "跳转到选择挂靠公司列表页面.", CurrentThreadContext.getCurrentUserName());
		view.addObject("dtlId", dtlId);
		view.addObject("prdTypCd", prdTypCd);
		view.addObject("prdTypNm", prjPrd.getPrdNm());
		view.addObject("gpsNmList", gpsNmList);
		view.addObject("gpsTypList", gpsTypList);
		/*view.addObject("prd", vo);*/
		view.addObject("detailFlag", detailFlag);// 是否详情页面：true false
		view.addObject("isMust",isMust);//null
		view.addObject("isMust",isMust);
		view.addObject("cvo",cvo);
		view.addObject("Caralter",Caralter);//控制商助修改车辆显示的字段
		view.addObject("projectApproval",projectApproval);//
		view.addObject("ZCdetail",ZCdetail);//仅用来控制专车
		view.addObject("taskDefKey",taskDefKey);//商助GPS审核节点

		return view;
	}
	
	/**
	 * 到车辆信息修改页面(卡车)
	 * 系统运维功能使用了这个页面
	 * 项目明细 点击产品名称 使用了这个页面
	 * @param auth 是否能换品牌车系（修改项目产品） 1：是 0：否
	 */
	@RequestMapping(value = "/toModifyPrjPrdDtlPrdInfoPage.do", method = { RequestMethod.GET})
	public ModelAndView toPrjPrdDtlPage(HttpServletRequest request, HttpServletResponse response,@RequestParam(required = false,defaultValue = "0") String auth){
		String detailFlag = request.getParameter("detailFlag");
		String dtlId = request.getParameter("dtlId");
		String prdTypCd = request.getParameter("prdTypCd");//产品分类

		String ywParam = request.getParameter("ywParam");
		String hasCarFlag = request.getParameter("hasCarFlag");
		String prjTypCd = request.getParameter("prjTypCd");//项目类型
		String isAuditNode = request.getParameter("isAuditNode");//信审节点标识
		PrjPrdDtlVO dtlVO  = null;
		//产品分类不存在根据产品明细ID查询
		if(StringUtils.isNotBlank(dtlId)){
			 dtlVO = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));
			if(null!=dtlVO){
				PrjPrdBscInfoVO prjPrd = this.prjPrdBscInfoService.selectById(dtlVO.getPrjPrdId());
				if(null!=prjPrd){
					prdTypCd = prjPrd.getPrdTypCd();
				}
			}
		}
		 dtlVO = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));
		List<KeyValueVO> brTypCdList  =  this.prjBscInfoService.getBrTypCdList();
		//板材材质
		List<KeyValueVO> matQalCdList = this.prjPrdBscInfoService.getMatQalCdList();
		//举升方式 
		List<KeyValueVO> liftWayCdList = this.prjPrdBscInfoService.getLiftWayCdList();
		//轮胎规格*数量 
		List<KeyValueVO> trlWhlSpecList = this.prjPrdBscInfoService.getTrlWhlSpecList();
		
		int tkFlag=0;
		if(!(prdTypCd.equals(CarStyleConstant.PRD_TYPE_7) ||prdTypCd.equals(CarStyleConstant.PRD_TYPE_52))){
			tkFlag = BaseConstant.IS_YESNO_YES;
		}
		ModelAndView view = new ModelAndView("project/prjprddtl/projectPrdDtlInfoAdd");
		//SysCdMapDVO map = 	this.prjPrdBscInfoService.searchBizCodeByPrdCd(prdTypCd);
		//更多的gps卡号
//		PrjPrdDtlGpsQC condition = new PrjPrdDtlGpsQC();
//		condition.setPrjDtlId(Long.valueOf(dtlId));
//		List<PrjPrdDtlGpsVO> voList = this.prjPrdDtlGpsService.searchList(condition);
//		view.addObject("moreGpsList", voList);

		// 获取GPS卡号
		PrjPrdDtlGpsQueryCondition gpsQC = new PrjPrdDtlGpsQueryCondition();
		gpsQC.setPrjDtlId(Long.valueOf(dtlId));
		List<PrjPrdDtlGpsVO> gpsVOList = this.prjPrdDtlGpsService.searchList(gpsQC);
		if (CollectionUtils.isNotEmpty(gpsVOList)) {
			for (PrjPrdDtlGpsVO vo : gpsVOList) {
				if (null != vo.getSerialNo()){
					if (vo.getSerialNo() == 1) {
						dtlVO.setGpsCardNo((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));

					} else if (vo.getSerialNo() == 2) {
						dtlVO.setGpsCardNo2((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr2((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd2((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));

					} else if (vo.getSerialNo() == 3) {
						dtlVO.setGpsCardNo3((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
						dtlVO.setGpsMfr3((null == vo.getGpsMfr()) ? "" : vo.getGpsMfr());
						dtlVO.setGpsTypCd3((null == vo.getGpsTypCd() ? "" : vo.getGpsTypCd()));
					}
				}

			}
		}


		PrjPrdDtlExtDTO prjPrdDtlExtDTO = prjPrdDtlExtApiService.selectById(Long.valueOf(dtlId));
		if(prjPrdDtlExtDTO!=null){
			String brTypCd = prjPrdDtlExtDTO.getBrTypCd();
			if(StringUtils.isNotBlank(brTypCd)){
				for (KeyValueVO vo : brTypCdList) {
					if(vo.getKey().equals(brTypCd)){
						prjPrdDtlExtDTO.setBrTypCd(vo.getValue());
					}
				}
			}
		}


		String prdCd = null ;
		PrjPrdBscInfoVO prjPrd = null ;
		if(dtlVO != null){
			 prjPrd = this.prjPrdBscInfoService.selectById(dtlVO.getPrjPrdId());
			 prdCd= prjPrd.getPrdCd();
		}
		if(prjPrdDtlExtDTO != null && StringUtils.isNotBlank(prdCd) && (prdCd.equals(CarStyleConstant.PRD_TYPE_7) || prdCd.equals(CarStyleConstant.PRD_TYPE_52))){
			view = new ModelAndView("project/prjprddtl/projectPrdDtlBusInfoAdd");
			if(StringUtils.isNotBlank(prdCd) && prdCd.equals(CarStyleConstant.PRD_TYPE_52)){
				if(ywParam!=null && ywParam.equals("1") ){ // 客车
					view = new ModelAndView("error");
				}else {
					view.addObject("prd", prjPrdDtlExtDTO);
					view.addObject("prjPrd",prjPrd);
				}
			}else{
				view.addObject("brTypCdList", brTypCdList);
//				view.addObject("drvTypList", drvTypList);
//				view.addObject("hpList", hpList);
				view.addObject("matQalCdList", matQalCdList);
				view.addObject("liftWayCdList", liftWayCdList);
				view.addObject("trlWhlSpecList", trlWhlSpecList);
			}
		}
		if(prjPrd != null){
            PrjBscInfoDTO prjBscInfoDTO = this.projectApiService.selectPrjBscInfoById(prjPrd.getPrjId(), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
            view.addObject("prj",prjBscInfoDTO);
			PrjPrdExtDTO prjPrdExtDTO = this.prjPrdExtApiService.selectById(prjPrd.getId());
			BaseLogUtils.newWebLogger("==获取二手车相关车源信息=prjPrdExtDTO:" + JSON.toJSONString(prjPrdExtDTO)).info();
			view.addObject("prjPrdExt", prjPrdExtDTO);
			PrjPrdSourceInfoDTO prjPrdSourceInfoDTO = this.projectApiService.selectPrjPrdSourceInfoById(prjPrd.getId());
			BaseLogUtils.newWebLogger("==获取二手车相关车源检测信息=prjPrdSourceInfoDTO:" + JSON.toJSONString(prjPrdSourceInfoDTO)).info();
			view.addObject("prdSourceInfo", prjPrdSourceInfoDTO);
			String pdfFilepath = null;
			if (prjPrdSourceInfoDTO != null && prjPrdSourceInfoDTO.getPdfFilePath() != null){
				pdfFilepath = PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH)+prjPrdSourceInfoDTO.getPdfFilePath();
			}
			view.addObject("pdfFilepath", pdfFilepath);
        }

		BaseLogUtils.info(logger, "toListPage", "跳转到选择挂靠公司列表页面.", CurrentThreadContext.getCurrentUserName());
		view.addObject("dtlId", dtlId);
		view.addObject("prdTypCd", prdTypCd);
		view.addObject("tkFlag",tkFlag);
		view.addObject("ywParam", ywParam);
		view.addObject("detailFlag", detailFlag);
		view.addObject("dtlVO", dtlVO);
		view.addObject("hasCarFlag", hasCarFlag);
		view.addObject("prd", prjPrdDtlExtDTO);
		view.addObject("prjPrd",prjPrd);
		view.addObject("auth",auth);
		view.addObject("prjTypCd",prjTypCd);
		view.addObject("isAuditNode",isAuditNode);
		return view;
	}
	/**
	 * 到选择挂靠公司列表页面
	 */
	@RequestMapping(value = "/toChooseLnkCompPage.do", method = { RequestMethod.GET})
	public ModelAndView toChooseLnkCompPage(HttpServletRequest request, HttpServletResponse response) {
        String dtlId = request.getParameter("dtlId");//产品明细ID
        String ids = request.getParameter("ids");
        String prjId = request.getParameter("prjId");//项目ID
		String vehNo = request.getParameter("vehNo");
		String splId = request.getParameter("splId");//经销商id
		String prjPrdChangeFlag = request.getParameter("prjPrdChangeFlag");
        ModelAndView view = new ModelAndView("project/prjprddtl/prdLnkCompListPage");
		view.addObject("prjPrdChangeFlag", prjPrdChangeFlag);
		view.addObject("prjId", prjId);
		view.addObject("vehNo", vehNo);
		view.addObject("splId", splId);
        BaseLogUtils.info(logger, "toListPage", "跳转到选择挂靠公司列表页面.", CurrentThreadContext.getCurrentUserName());
        if (null == dtlId) {
            PrjBscInfoVO bscVo = this.prjBscInfoService.selectById(Long.valueOf(prjId));
            view.addObject("ids", ids);
            view.addObject("prjTypCd", bscVo.getPrjTypCd());
            return view;
        }
        PrjPrdDtlVO dtlVO = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));//项目产品明细表
        view.addObject("dtlId", dtlId);
        view.addObject("dtlVO", dtlVO);
        return view;
	}
    /**
     * 到选择产品列表页面
     * @param auth 是否拥有换品牌和车系的权限，1：是 0 否
     */
    @RequestMapping(value = "/toChoosePrdListPage.do", method = { RequestMethod.GET, RequestMethod.POST })
    public ModelAndView toChoosePrdListPage(ModelAndView view,HttpServletRequest request, HttpServletResponse response,String brCd,String modelName,
                                            @RequestParam(required = false,defaultValue = "0") String auth) {
        logger.info("到项目产品列表页面.");
        String prdId = request.getParameter("prdId");
        String prdTypCd = request.getParameter("prdTypCd");//产品分类
        String prdNm = request.getParameter("prdNm");//产品名称
        if(prdTypCd.equals(CarStyleConstant.PRD_TYPE_9)){
            view.setViewName("/project/prjprddtl/chooseTrailerList");
        }else{
            view = new ModelAndView("project/prjprddtl/chooseVehicleList");
        }
        view.addObject("prdId", prdId);
        view.addObject("prdTypCd", prdTypCd);
        view.addObject("prdNm", prdNm);
        view.addObject("brCd",brCd);
        view.addObject("modelName",modelName);
        view.addObject("auth",auth);
        return view;
    }
	/**
	 * 到产品明细列表页面
	 */
	@RequestMapping(value = "/toPrjPrdDtlListPage.do", method = { RequestMethod.GET})
	public ModelAndView toPrjPrdDtlListPage(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");
		String prjPrdId = request.getParameter("prjPrdId");
		String prdFlag = request.getParameter("prdFlag");
		String detailFlag = request.getParameter("detailFlag");
		String ywParam = request.getParameter("ywParam");
		String buOrgCd = request.getParameter("buOrgCd");
		// 车牌号
		String carNo = request.getParameter("carNo");

		//查重用
		String cstId = request.getParameter("cstId");
		String cstTypCd = request.getParameter("cstTypCd");
		String isDetail = request.getParameter("isDetail");//是否信审节点  0:信审节点

		ModelAndView view = new ModelAndView("project/prjprddtl/prjPrdDtlListPage");
		//  轻卡审核页面
		String lcvCheck = request.getParameter("lcvCheck");//轻卡参数
		if(StringUtils.isNotEmpty(lcvCheck) && !"".equals(lcvCheck)){
			view.setViewName("project/prjprddtl/prjPrdDtlListPageLcv");
			view.addObject("lcvCheck", lcvCheck);
			String lcvCheckLnkCompUrl = PropertiesCacheUtils.getProperty("web.web.properties.lcv.check.lnkComp.url");
			view.addObject("lcvCheckLnkCompUrl", lcvCheckLnkCompUrl);
		}

		BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		view.addObject("prjId", prjId);
		view.addObject("prjPrdId", prjPrdId);
		view.addObject("prdFlag", prdFlag);
		view.addObject("detailFlag", detailFlag);
		view.addObject("ywParam", ywParam);
		view.addObject("cstId",cstId);
		view.addObject("cstTypCd",cstTypCd);
		view.addObject("carNo", carNo);
		view.addObject("isDetail", isDetail);

		PrjBscInfoVO prjBscInfoVO = prjBscInfoService.selectById(Long.valueOf(prjId));
		view.addObject("buOrgCd", prjBscInfoVO.getBuOrgCd());
		view.addObject("prjTypCd", prjBscInfoVO.getPrjTypCd());
		view.addObject("cstMgrOrgCd",prjBscInfoVO.getCstMgrOrgCd());
		//********流程参数开始********//
		String preTaskIds = request.getParameter("preTaskIds");//流程上一个节点任务ID,多个以逗号分割.
		String pInstId = request.getParameter("pInstId");//流程实例ID
		view.addObject("pInstId", pInstId);
		view.addObject("preTaskIds", preTaskIds);
		//********流程参数结束********//
		
		return view;
	}

	
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");
		String prjPrdId = request.getParameter("prjPrdId");
		String prdFlag = request.getParameter("prdFlag");
		String detailFlag = request.getParameter("detailFlag");
		int quotePrpsExist=BaseConstant.IS_YESNO_NO ;//是否显示报价版支付表信息
		PrjQuatPrpsQueryCondition qc = new PrjQuatPrpsQueryCondition();
		qc.setIsFormalPrps(BaseConstant.IS_YESNO_YES);
		qc.setPrpsTypCd(PrjQuatPrpsConstant.CODE_PRJ_QUAT_TYP_QUOTE);
		qc.setPrjId(Long.valueOf(prjId));
		List<PrjQuatPrpsVO> quatList = 	this.prjQuatPrpsService.searchList(qc);
		if(CollectionUtils.isNotEmpty(quatList)){
			quotePrpsExist = BaseConstant.IS_YESNO_YES;
		}else{
			quotePrpsExist=BaseConstant.IS_YESNO_NO;
		}
		/*PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
		if(StringUtils.isNotBlank(prjBscInfoVO.getInsCode())&&prjBscInfoVO.getInsCode().equals(PrjBscInfoConstant.PRJ_INS_CODE_ICBC)){
			detailFlag= "true";
		}*/
		ModelAndView view = new ModelAndView("project/prjprdquatprps/prjPrdQuatPrpsList");
		BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		view.addObject("prjId", prjId);
		view.addObject("prjPrdId", prjPrdId);
		view.addObject("prdFlag", prdFlag);
		view.addObject("detailFlag", detailFlag);
		view.addObject("quotePrpsExist", quotePrpsExist);
		
		//********流程参数开始********//
		String preTaskIds = request.getParameter("preTaskIds");//流程上一个节点任务ID,多个以逗号分割.
		String pInstId = request.getParameter("pInstId");//流程实例ID
		view.addObject("pInstId", pInstId);
		view.addObject("preTaskIds", preTaskIds);
		//********流程参数结束********//
		PrjBscInfoVO prjBscInfoVO = prjBscInfoService.selectById(Long.parseLong(prjId));
		view.addObject("prjTypeCd", prjBscInfoVO.getPrjTypCd() == null ? "" : prjBscInfoVO.getPrjTypCd());
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("project/prjPrdDtl/modify");
		view.addObject("id", id);
		BaseLogUtils.info(logger, "toModifyPage", "跳转到修改页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到拆分页面
	 */
	@RequestMapping(value = "/toSplitPrjPrdQuatPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toSplitPrjPrdQuatPage(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");
		ModelAndView view = new ModelAndView("project/prjprdquatprps/splitPrjPrdQuatPrps");
		List<Long> idList = new ArrayList<Long>();
		if(StringUtils.isNotBlank(prjId)){
			if(StringUtils.isNotBlank(prjId)){
				PrjPrdBscInfoQueryCondition prjPrdqc = new PrjPrdBscInfoQueryCondition();
				prjPrdqc.setPrjId(Long.valueOf(prjId));
				List<PrjPrdBscInfoVO> prjPrdList = this.prjPrdBscInfoService.searchList(prjPrdqc);
				if(CollectionUtils.isNotEmpty(prjPrdList)){
					for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
						idList.add(prjPrdBscInfoVO.getId());
					}
				}
			}
		}
		view.addObject("prjId", prjId);
		BaseLogUtils.info(logger, "toSplitPrjPrdQuatPage", "跳转到修改页面.[id="+prjId+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		// 项目id
		String prjId = request.getParameter("prjId");
		// 项目产品id
		String prjPrdId = request.getParameter("prjPrdId");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		PrjPrdDtlQueryCondition qc = new PrjPrdDtlQueryCondition();
		if (StringUtils.isNotBlank(prjPrdId)) {
			qc.setPrjPrdId(Long.valueOf(prjPrdId));
		}
		List<Long> idList = new ArrayList<Long>();
		if (StringUtils.isNotBlank(prjId)) {
			PrjPrdBscInfoQueryCondition prjPrdqc = new PrjPrdBscInfoQueryCondition();
			prjPrdqc.setPrjId(Long.valueOf(prjId));
			List<PrjPrdBscInfoVO> prjPrdList = this.prjPrdBscInfoService.searchList(prjPrdqc);
			if (CollectionUtils.isNotEmpty(prjPrdList)) {
				for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
					idList.add(prjPrdBscInfoVO.getId());
				}
			} else {
				ListPageVO<PrjPrdDtlVO> listPage = new ListPageVO<PrjPrdDtlVO>(new ArrayList<PrjPrdDtlVO>(), 0);
				return listPage;
			}
		}
		qc.setPrjId(Long.valueOf(prjId));
		qc.setPrjPrdIdList(idList);
		page.setCondition(qc);

		//TODO SOMETHING
		Pager pager = this.prjPrdDtlService.searchListPage(page);
		List<PrjPrdDtlVO> list = (List<PrjPrdDtlVO>) pager.getResultList();
		BaseLogUtils.info(logger, "initList", "查询数据完成. list:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());

		if (CollectionUtils.isNotEmpty(list)) {
			List<SysDictionaryDTO> lnkStartLvlList = this.sysDictionaryApiService.searchGroup(WebBaseConstant.SPL_SYS_CD, CurrentThreadContext.getCurrentOrgCd(), PrjPrdDtlConstant.CODE_GRP_CD_START_LVL);
			for (PrjPrdDtlVO prjPrdDtlVO : list) {
				if (null == prjPrdDtlVO.getLnkCompNm()) {
					prjPrdDtlVO.setLnkCompNm(" ");
				}

				// 获取GPS卡号
				PrjPrdDtlGpsQueryCondition gpsQC = new PrjPrdDtlGpsQueryCondition();
				gpsQC.setPrjDtlId(prjPrdDtlVO.getId());
				List<PrjPrdDtlGpsVO> gpsVOList = this.prjPrdDtlGpsService.searchList(gpsQC);
				BaseLogUtils.info(logger, "initList", "查询GPS,PrjPrdDtlGpsQC:" + JSON.toJSONString(gpsQC), CurrentThreadContext.getCurrentUserName());
				BaseLogUtils.info(logger, "initList", "查询GPS,List<PrjPrdDtlGpsVO>:" + JSON.toJSONString(gpsVOList), CurrentThreadContext.getCurrentUserName());

				if (CollectionUtils.isNotEmpty(gpsVOList)) {
					for (PrjPrdDtlGpsVO vo : gpsVOList) {
						if (null != vo.getSerialNo()) {
							if (vo.getSerialNo() == 1) {
								prjPrdDtlVO.setGpsCardNo((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
							} else if (vo.getSerialNo() == 2) {
								prjPrdDtlVO.setGpsCardNo2((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
							} else if (vo.getSerialNo() == 3) {
								prjPrdDtlVO.setGpsCardNo3((null == vo.getGpsCardNo()) ? "" : vo.getGpsCardNo());
							}
						}

					}
				}
				/**
				 * 翻译挂靠公司星级
				 */
				if(CollectionUtils.isNotEmpty(lnkStartLvlList)){
					Long lnkStartLvl = prjPrdDtlVO.getLnkStartLvl();
					if(lnkStartLvl != null){
						for (SysDictionaryDTO sysDictionaryDTO : lnkStartLvlList) {
							String code = sysDictionaryDTO.getCode();
							if (lnkStartLvl.equals(Long.valueOf(code))) {
								prjPrdDtlVO.setLnkStartLvlNm(sysDictionaryDTO.getCodeNm());
							}
						}
					}
				}
				// 获取车牌号
				PrjPrdLicInfoVO licInfoVO = this.prjPrdLicInfoService.selectById(prjPrdDtlVO.getId());
				prjPrdDtlVO.setVehNo("");
				if (licInfoVO != null ){
					prjPrdDtlVO.setVehNo((StringUtils.isNotBlank(licInfoVO.getVehNo())?licInfoVO.getVehNo():""));
				}
			}

			// 把征信车牌的第一个给产品明细的第一个,并入库
//			if (list.get(0) != null){
//				if(StringUtils.isBlank(list.get(0).getVehNo())){
//					List<String> vehNoList = this.projectApiService.getVehNoByCredit(Long.valueOf(prjId), CurrentThreadContext.getCurrentSysCd(),
//							CurrentThreadContext.getCurrentOrgCd(), CurrentThreadContext.getCurrentBuOrgCd());
//					if (CollectionUtils.isNotEmpty(vehNoList)){
//						list.get(0).setVehNo(vehNoList.get(0));
//
//						PrjPrdLicInfoVO licInfoVO = new PrjPrdLicInfoVO();
//						licInfoVO.setId(list.get(0).getId());
//						licInfoVO.setVehNo(vehNoList.get(0));
//						licInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
//						licInfoVO.setCrtTm(new Date());
//						this.prjPrdLicInfoService.add(licInfoVO);
//					}
//				}
//			}

		}
        BaseLogUtils.info(logger, "initList", "查询挂靠公司逾期率和高风险预警接口开始=prjId:" + prjId, CurrentThreadContext.getCurrentUserName());
        if(CollectionUtils.isNotEmpty(list)){
			List<Long> lnkCompIds = new ArrayList();
			for (PrjPrdDtlVO prjPrdDtlVO : list){
				if (StringUtils.isNotEmpty(prjPrdDtlVO.getLnkCompId())){
					CapChnOvdRateQC capChnOvdRateQC = new CapChnOvdRateQC();
					capChnOvdRateQC.setChnId(prjPrdDtlVO.getLnkCompId());
					capChnOvdRateQC.setChnTypCd("2"); //1.供应商 2.挂靠公司
					capChnOvdRateQC.setOrderBy("OVD_MONTH");
					List<CapChnOvdRateDTO> capChnOvdRateDTOList = this.capChnOvdRateApiService.searchListByCondition(capChnOvdRateQC);
					BaseLogUtils.info(logger, "initList", "查询挂靠公司逾期率返回：" + JSONObject.toJSONString(capChnOvdRateDTOList), CurrentThreadContext.getCurrentUserName());
					if (CollectionUtils.isNotEmpty(capChnOvdRateDTOList)){
						CapChnOvdRateDTO capChnOvdRateDTO = capChnOvdRateDTOList.get(0);
						prjPrdDtlVO.setEverRate(capChnOvdRateDTO.getEverRate()== null ? 0:capChnOvdRateDTO.getEverRate());//Ever逾期%
						prjPrdDtlVO.setPotRate(capChnOvdRateDTO.getPotRate()== null ? 0:capChnOvdRateDTO.getPotRate());//时点逾期%
					}else {
						prjPrdDtlVO.setEverRate(0d);//Ever逾期%
						prjPrdDtlVO.setPotRate(0d);//时点逾期%
					}
				} else {
					prjPrdDtlVO.setEverRate(0d);//Ever逾期%
					prjPrdDtlVO.setPotRate(0d);//时点逾期%
				}
				lnkCompIds.add(prjPrdDtlVO.getLnkCompId());//挂靠公司ids
			}
			SplHRiskWarnRecQC splHRiskWarnRecQC = new SplHRiskWarnRecQC();
			splHRiskWarnRecQC.setDataIdList(lnkCompIds);
			splHRiskWarnRecQC.setDataTyp("LNK"); //SPL:供应商  LNK:挂靠公司
			splHRiskWarnRecQC.setIsWarn(1);
			splHRiskWarnRecQC.setIsDel(0);
			splHRiskWarnRecQC.setIsValid(1);
			splHRiskWarnRecQC.setIsNew(1);
			List<SplHRiskWarnRecDTO> splHRiskWarnRecDTOList = splHRiskWarnRecApiService.checkSplHRiskWarnRecDTOByQC(splHRiskWarnRecQC,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(), WebBaseConstant.CHANNEL_CD);
			BaseLogUtils.info(logger, "initList", "查询挂靠公司高风险预警接口返回：" + JSONObject.toJSONString(splHRiskWarnRecDTOList), CurrentThreadContext.getCurrentUserName());
			for (PrjPrdDtlVO prjPrdDtlVO : list){
				if (CollectionUtils.isNotEmpty(splHRiskWarnRecDTOList)){
					for (SplHRiskWarnRecDTO splHRiskWarnRecDTO : splHRiskWarnRecDTOList){
						if (Objects.equals(splHRiskWarnRecDTO.getDataId(), prjPrdDtlVO.getLnkCompId())) {
							prjPrdDtlVO.setRiskWarnCd("1");
						}
					}
				}
			}
		}
		ListPageVO<PrjPrdDtlVO> listPage = new ListPageVO<PrjPrdDtlVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 拆分项目产品及项目支付表
	 */
	@RequestMapping(value = "/splitPrjPrdAndPaySch.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO splitPrjPrdAndPaySch(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String prjPrdId = request.getParameter("prjPrdId");//项目产品id
		String prjId = request.getParameter("prjId");//项目id
		String prjPrdIdList = request.getParameter("prjPrdIdList");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(prjPrdIdList)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			if(StringUtils.isBlank(prjId)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
				return result;
			}
			List<Long> idList = new ArrayList<Long>();
			PrjPrdBscInfoQueryCondition qc = new PrjPrdBscInfoQueryCondition();
			qc.setPrjId(Long.valueOf(prjId));
			List<PrjPrdBscInfoVO> list = this.prjPrdBscInfoService.searchList(qc);
			if(CollectionUtils.isNotEmpty(list)){
				for (PrjPrdBscInfoVO prjPrdBscInfoVO : list) {
					idList.add(prjPrdBscInfoVO.getId());
				}
			}
			/*JSONArray idsArray = JSONArray.fromObject(prjPrdIdList);
			for (Object object : idsArray) {
				idList.add(Long.valueOf(object.toString()));
			}*/
			this.prjPrdDtlService.modifySplitPrjPrdAndPaySch(idList,Long.valueOf(prjId));
			BaseLogUtils.info(logger, "removeById", "拆分数据.[id="+prjPrdId+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "拆分数据失败.[id="+prjPrdId+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "拆分数据失败.[id="+prjPrdId+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		List<Long> idList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idList.add(Long.valueOf(object.toString()));
		}
		try {
			this.prjPrdDtlService.removeByIds(idList);
			for (Long prjPrdDtlId : idList) {
				PrjPrdInvoiceQueryCondition condition = new PrjPrdInvoiceQueryCondition();
				condition.setPrjPrdDtlId(prjPrdDtlId);
				ResponseData responseData = prjPrdInvoiceApiService.selectList(condition);
				if(responseData.getData() != null){
					List<PrjPrdInvoiceDTO> prjPrdInvoiceDTOS = (List<PrjPrdInvoiceDTO>) responseData.getData();
					for(PrjPrdInvoiceDTO dto : prjPrdInvoiceDTOS){
						dto.setIsDel(1);
						prjPrdInvoiceApiService.modify(dto);
					}
				}
			}
			BaseLogUtils.info(logger, "removeById", "删除数据.[id="+idList+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除数据失败.[id="+idList+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除数据失败.[id="+idList+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrjPrdDtlVO vo = this.prjPrdDtlService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjPrdDtlVO entity = null;
		try {
			entity = new PrjPrdDtlVO();
			//TODO ADD PARAM
			Long id = this.prjPrdDtlService.add(entity);
			result.setData(id);
			BaseLogUtils.info(logger, "add", "新增数据.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 校验GPS
	 * @param dtlId 产品明细id
	 * @param gpsNums GPS卡号字符串，如："卡号1,卡号2,"
	 */
	private void modifyVinAndGPS(String dtlId, String gpsNums){
		if(StringUtils.isNotBlank(dtlId)){
			// 验证GPS卡号
			String[] gpsNumsArray = gpsNums.split(",");
			if (!prjPrdDtlGpsService.cheakIsRepeat(gpsNumsArray)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"填写的GPS重复，请调整!");
			}
			if (gpsNumsArray.length > 0){
				for (int i = 0; i<gpsNumsArray.length; i++){
					Integer checkResult = prjPrdDtlGpsService.checkGPSExist(gpsNumsArray[i], Long.valueOf(dtlId));
					if (checkResult != 1){// 0表示占用 1表示未占用 2 数据错误
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,gpsNumsArray[i]+",当前资产GPS信息已在其它资产上绑定使用，请调整!");
					}
				}
			}

		}
	}

	@RequestMapping(value = "/validateGpsInfo.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object vaildateGpsCardNoHadoop(HttpServletRequest request, HttpServletResponse response) throws BaseException{
		String prjPrdDtlInfoList = request.getParameter("prjPrdDtlInfoList");
		String prjId = request.getParameter("prjId");// 项目id

		BaseLogUtils.newLogger("项目id:{},保存的时候校验gps卡号信息,参数:{}",prjId,JSON.toJSONString(prjPrdDtlInfoList)).info();

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES);
		if (StringUtils.isEmpty(prjPrdDtlInfoList) || StringUtils.isEmpty(prjId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newLogger("项目id:{},保存的时候校验gps卡号信息失败",prjId).info();
			return result;
		}

		// 装有三个gps卡号的
		List<PrjPrdDtlVO> list = new ArrayList<PrjPrdDtlVO>();
		if (StringUtils.isNotBlank(prjPrdDtlInfoList)) {
			com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(prjPrdDtlInfoList);
			for (Object jsonObject : jsonArray) {
				// 校验卡号有重复性
				List<String> list1 = new ArrayList<>();
				PrjPrdDtlVO vo = JSONObject.parseObject(jsonObject.toString(), PrjPrdDtlVO.class);
				String gps1 = StringUtils.isNotBlank(vo.getGpsCardNo()) ? vo.getGpsCardNo() : "0";
				String gps2 = StringUtils.isNotBlank(vo.getGpsCardNo2()) ? vo.getGpsCardNo2() : "0";
				String gps3 = StringUtils.isNotBlank(vo.getGpsCardNo3()) ? vo.getGpsCardNo3() : "0";

				list1.add(gps1);
				list1.add(gps2);
				list1.add(gps3);

				BaseLogUtils.newLogger("项目id:{},校验gps卡号重复性:{}",prjId,JSON.toJSONString(list1)).info();

				List checkList = new ArrayList();
				for(String gpsCardNo:list1){
					if(StringUtils.isNotBlank(gpsCardNo) && !gpsCardNo.equals("0")){
						if(checkList.contains(gpsCardNo)){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("GPS卡号有重复,请核查!");
							return result;
						}
						checkList.add(gpsCardNo);
					}
				}
				list.add(vo);
			}
		}




		/*
		 * 对gps卡号的校验
		 * 1、数字15位
		 * 2、纯数字
		 */
		List<String> errorMsgList = new ArrayList<>();
		if (CollectionUtils.isNotEmpty(list)) {
			for (PrjPrdDtlVO prjPrdDtlVO : list) {
				validateGpsCardNo(prjPrdDtlVO.getGpsCardNo(),errorMsgList);
				validateGpsCardNo(prjPrdDtlVO.getGpsCardNo2(),errorMsgList);
				validateGpsCardNo(prjPrdDtlVO.getGpsCardNo3(),errorMsgList);
			}
		}

		if (CollectionUtils.isNotEmpty(errorMsgList)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(errorMsgList.toString());
			BaseLogUtils.newLogger("项目id:{},保存的时候对gps卡号校验的错误信息集合:{}",prjId,JSON.toJSONString(result)).info();
			return result;
		}

		// 查询业务员工号
		String customManagerWorkNum = selectCustomManagerWorkNum(prjId);
		if (StringUtils.isEmpty(customManagerWorkNum)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("项目id:" + prjId + ",未查询到当前客户经理工号!");
			BaseLogUtils.newLogger("项目id:{},未查询到当前客户经理工号:{}",prjId,JSON.toJSONString(result)).info();
			return result;
		}

		try {
			if (CollectionUtils.isNotEmpty(list)) {
				for (PrjPrdDtlVO prjPrdDtlVO : list) {
					List<String> hintMsgList = new ArrayList<>();

					// 校验库里的卡号跟前端的卡号是否一致
					// 不一致，再调用后续的校验
					// 一致，就不需要校验了
					String gpsCardNo = StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo() : "0";
					String gpsCardNo2 = StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2() : "0";
					String gpsCardNo3 = StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3() : "0";

					List<PrjPrdDtlGpsVO> gpsOneList = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 1);
					BaseLogUtils.newLogger("项目id:{},gps序号1,前端的gps卡号:{},从库里查询的数据:{}",prjId,gpsCardNo,CollectionUtils.isNotEmpty(gpsOneList) ? JSON.toJSONString(gpsOneList) : "空集合").info();

					if (CollectionUtils.isNotEmpty(gpsOneList)) {
						PrjPrdDtlGpsVO prjPrdDtlGpsVO = gpsOneList.get(0);

						if (!Objects.equals(prjPrdDtlGpsVO.getGpsCardNo(),gpsCardNo)) {
							String isUsedGpsOne = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 1);
							if (StringUtils.isNotBlank(isUsedGpsOne)) {
								if (Objects.equals("1", isUsedGpsOne)) {
									// 未占用
									queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 1,hintMsgList);
								} else {
									throw new BaseException(prjPrdDtlVO.getGpsCardNo() + ",已经占用,请核查!");
								}
							}
						}
					} else {
						String isUsedGpsOne = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 1);
						if (StringUtils.isNotBlank(isUsedGpsOne)) {
							if (Objects.equals("1", isUsedGpsOne)) {
								// 未占用
								queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 1,hintMsgList);
							} else {
								throw new BaseException(prjPrdDtlVO.getGpsCardNo() + ",已经占用,请核查!");
							}
						}
					}

					List<PrjPrdDtlGpsVO> gpsSecondList = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 2);
					BaseLogUtils.newLogger("项目id:{},gps序号2,前端的gps卡号:{},从库里查询的数据:{}",prjId,gpsCardNo2,CollectionUtils.isNotEmpty(gpsSecondList) ? JSON.toJSONString(gpsSecondList) : "空集合").info();

					if (CollectionUtils.isNotEmpty(gpsSecondList)) {
						PrjPrdDtlGpsVO prjPrdDtlGpsVO = gpsSecondList.get(0);

						if (!Objects.equals(prjPrdDtlGpsVO.getGpsCardNo(),gpsCardNo2)) {
							String isUsedGpsSecond = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 2);
							if (StringUtils.isNotBlank(isUsedGpsSecond)) {
								if (Objects.equals("1", isUsedGpsSecond)) {
									// 未占用
									queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 2,hintMsgList);
								} else {
									throw new BaseException(prjPrdDtlVO.getGpsCardNo2() + ",已经占用,请核查!");
								}
							}
						}
					} else {
						String isUsedGpsSecond = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 2);
						if (StringUtils.isNotBlank(isUsedGpsSecond)) {
							if (Objects.equals("1", isUsedGpsSecond)) {
								// 未占用
								queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 2,hintMsgList);
							} else {
								throw new BaseException(prjPrdDtlVO.getGpsCardNo2() + ",已经占用,请核查!");
							}
						}
					}

					List<PrjPrdDtlGpsVO> gpsThreeList = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 3);
					BaseLogUtils.newLogger("项目id:{},gps序号3,前端的gps卡号:{},从库里查询的数据:{}",prjId,gpsCardNo3,CollectionUtils.isNotEmpty(gpsThreeList) ? JSON.toJSONString(gpsThreeList) : "空集合").info();

					if (CollectionUtils.isNotEmpty(gpsThreeList)) {
						PrjPrdDtlGpsVO prjPrdDtlGpsVO = gpsThreeList.get(0);

						if (!Objects.equals(prjPrdDtlGpsVO.getGpsCardNo(),gpsCardNo3)) {
							String isUsedGpsThree = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 3);
							if (StringUtils.isNotBlank(isUsedGpsThree)) {
								if (Objects.equals("1", isUsedGpsThree)) {
									// 未占用
									queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 3,hintMsgList);
								} else {
									throw new BaseException(prjPrdDtlVO.getGpsCardNo3() + ",已经占用,请核查!");
								}
							}
						}
					} else {
						String isUsedGpsThree = gpsDeviceIsUsed(prjId, prjPrdDtlVO, 3);
						if (StringUtils.isNotBlank(isUsedGpsThree)) {
							if (Objects.equals("1", isUsedGpsThree)) {
								// 未占用
								queryGpsDeviceInfoOfHadoop(prjId, customManagerWorkNum, prjPrdDtlVO, 3,hintMsgList);
							} else {
								throw new BaseException(prjPrdDtlVO.getGpsCardNo3() + ",已经占用,请核查!");
							}
						}
					}


					BaseLogUtils.newLogger("项目id:{},保存的时候错误信息:hintMsgList:{}",prjId,hintMsgList.toString()).info();

					if (CollectionUtils.isNotEmpty(hintMsgList)) {
						DataResultVO dataResultVO = new DataResultVO();
						dataResultVO.setSuccess(BaseConstant.IS_YESNO_YES);
						dataResultVO.setInfo(hintMsgList.toString());
						return dataResultVO;
					}
				}
			}
		} catch (BaseException e) {
			BaseLogUtils.newLogger("项目id:{},保存的时候校验异常:",prjId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
		} catch (Exception e) {
			BaseLogUtils.newLogger("项目id:{},保存的时候校验异常:",prjId).setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
		}

		return result;

	}



	/**
	 * 修改GPS卡号、车架号(vin)、车牌号
	 */
	@RequestMapping(value = "/modifyGpsInfos.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object modifyGpsInfos(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String prjPrdDtlInfoList = request.getParameter("prjPrdDtlInfoList");
		String prjTypCd = request.getParameter("prjTypCd");// 项目类型
		String prjId = request.getParameter("prjId");// 项目id
		BaseLogUtils.info(logger, "modifyGpsInfos", "维护车牌号, prjPrdDtlInfoList："+ JSON.toJSONString(prjPrdDtlInfoList),CurrentThreadContext.getCurrentUserName());

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if (StringUtils.isEmpty(prjPrdDtlInfoList)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyGpsInfos", "修改数据失败！", CurrentThreadContext.getCurrentUserName());
			return result;
		}

		List<PrjPrdDtlVO> list = new ArrayList<PrjPrdDtlVO>();
		String vehNoStr = "";
		if (StringUtils.isNotBlank(prjPrdDtlInfoList)) {
			com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(prjPrdDtlInfoList);
			for (Object jsonObject : jsonArray) {
				PrjPrdDtlVO vo = JSONObject.parseObject(jsonObject.toString(), PrjPrdDtlVO.class);
				list.add(vo);
				vehNoStr += vo.getVehNo() + ",";
			}
		}


		if (CollectionUtils.isNotEmpty(list)) {

			List<String> addedGpsDeviceList = new ArrayList<>();
			List<String> gpsCarNoList = new ArrayList<>();
			for(PrjPrdDtlVO prjPrdDtlVO : list){
				if(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) && !"0".equals(prjPrdDtlVO.getGpsCardNo())){
					addedGpsDeviceList.add(prjPrdDtlVO.getGpsCardNo());
				}
				if(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) && !"0".equals(prjPrdDtlVO.getGpsCardNo2())){
					addedGpsDeviceList.add(prjPrdDtlVO.getGpsCardNo2());
				}
				if(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) && !"0".equals(prjPrdDtlVO.getGpsCardNo3())){
					addedGpsDeviceList.add(prjPrdDtlVO.getGpsCardNo3());
				}
				PrjPrdDtlGpsQueryCondition prjPrdDtlGpsQueryCondition = new PrjPrdDtlGpsQueryCondition();
				prjPrdDtlGpsQueryCondition.setIsDel(0);
				prjPrdDtlGpsQueryCondition.setPrjDtlId(prjPrdDtlVO.getId());
				List<PrjPrdDtlGpsVO> prjPrdDtlGpsVOS = prjPrdDtlGpsService.searchList(prjPrdDtlGpsQueryCondition);
				if(CollectionUtils.isNotEmpty(prjPrdDtlGpsVOS)){
					for(PrjPrdDtlGpsVO prjPrdDtlGpsVO : prjPrdDtlGpsVOS){
						gpsCarNoList.add(prjPrdDtlGpsVO.getGpsCardNo());
					}
				}
			}

			// 查询业务员工号
			String customManagerWorkNum = selectCustomManagerWorkNum(prjId);
			if (StringUtils.isEmpty(customManagerWorkNum)) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("项目id:"+ prjId +",未查询到当前客户经理工号!");
				BaseLogUtils.newLogger("项目id:{},未查询到当前客户经理工号!",prjId).info();
				return result;
			}

			/*if(CollectionUtils.isNotEmpty(addedGpsDeviceList)){
				// 校验GPS卡号是否属于当前用户已领用
				PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
				String cstMgrOrgCd = prjBscInfoVO.getCstMgrOrgCd();
				if(StringUtils.isBlank(cstMgrOrgCd)){
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("未查询到客户经理组织机构代码");
					BaseLogUtils.info(logger, "modifyGpsInfos", "修改数据失败，未查询到客户经理组织机构代码！", CurrentThreadContext.getCurrentUserName());
					return result;
				}
				if(!cstMgrOrgCd.startsWith("000000080002")){
					List<String> gpsDeviceList = this.prjPrdDtlGpsService.getGpsDevice(prjBscInfoVO.getCstMgrId(),"2");
					for(String addedGps : addedGpsDeviceList){
						// 历史数据，已存在GPS已领用状态，大数据系统不返回，保存时不校验
						if(CollectionUtils.isNotEmpty(gpsCarNoList)){
							boolean containsFlag = false;
							for(String gpsCardNo : gpsCarNoList){
								if(Objects.equals(gpsCardNo,addedGps)){
									containsFlag = true;
									break;
								}
							}
							if(containsFlag){
								break;
							}
						}
						if(CollectionUtils.isEmpty(gpsDeviceList)){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("项目客户经理账号下未查询到设备，请核实");
							BaseLogUtils.info(logger, "modifyGpsInfos", "修改数据失败，GPS卡号录入有误，请核实！", CurrentThreadContext.getCurrentUserName());
							return result;
						}
						boolean flag = false;
						for(String gps : gpsDeviceList){
							if(Objects.equals(addedGps,gps)){
								flag = true;
								break;
							}
						}
						if(!flag){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("GPS卡号录入有误，请核实");
							BaseLogUtils.info(logger, "modifyGpsInfos", "修改数据失败，GPS卡号录入有误，请核实！gpsCarNo="+addedGps, CurrentThreadContext.getCurrentUserName());
							return result;
						}
					}
				}
			}*/

			if(!prjPrdDtlGpsService.cheakIsRepeat(vehNoStr.split(","))){
				vehNoStr = "";
//				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"填写的车牌号重复，请调整!");
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("填写的车牌号重复，请调整!");
				return result;
			}
			try {

				for (PrjPrdDtlVO prjPrdDtlVO : list) {

					BaseLogUtils.info(logger, "modifyGpsInfos", "维护车牌号, prjPrdDtlVO：" + JSON.toJSONString(prjPrdDtlVO), CurrentThreadContext.getCurrentUserName());
					BaseLogUtils.info(logger, "modifyGpsInfos", "维护车牌号, prjPrdDtlVO.get：" + prjPrdDtlVO.getVinValidRes(), CurrentThreadContext.getCurrentUserName());
					prjPrdDtlVO.setMdfTm(new Date());
					prjPrdDtlVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
					String vinValidRes = prjPrdDtlVO.getVinValidRes();
					if (StringUtils.isNotBlank(prjPrdDtlVO.getVin())) {
						if (!"1".equals(vinValidRes)) {
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("VIN校验错误！");
							return result;
						}
					}

					if (StringUtils.isNotBlank(prjTypCd) && (prjTypCd.equals("CDDYWUL") || prjTypCd.equals("OWNJYD")) && StringUtils.isNotBlank(prjPrdDtlVO.getVehNo()) && StringUtils.isNotBlank(prjId)) { // 项目类型：车抵贷业务线下
						// 项目类型：车抵贷业务线下、内转交易贷  校验车牌号是否合规
						if(!ValisityUtils.validityVehNo(prjPrdDtlVO.getVehNo())){
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("填写的车牌号错误，请调整!");
							return result;
						}
						// 校验车牌号重复
						Integer flag = this.projectApiService.verifyVehNoExist(prjPrdDtlVO.getVehNo(), Long.valueOf(prjId),prjPrdDtlVO.getId());
						if (null != flag && flag == 1) {
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo("该车牌号" + prjPrdDtlVO.getVehNo() + "已在其他车辆设备中使用！");
							return result;
						}
					}
				}
			} catch (Exception e) {
				BaseLogUtils.error(logger, "modifyGpsInfos", "校验vin和车牌号Exception :" + e, CurrentThreadContext.getCurrentUserName());
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				return result;
			}

			try {
				for (PrjPrdDtlVO prjPrdDtlVO : list) {
					// 校验车牌号c级,级别对应：1-A,2-B,3-C,4-AAA,5-AA
					if (StringUtils.isNotBlank(prjPrdDtlVO.getVehNo())) {
						String vehNoLevel = this.projectApiService.getVehNoLevel(prjPrdDtlVO.getVehNo(), CurrentThreadContext.getCurrentSysCd());
						if (StringUtils.isNotBlank(vehNoLevel) && vehNoLevel.equals("3")) {
							result.setSuccess(BaseConstant.IS_YESNO_NO);
							result.setInfo(prjPrdDtlVO.getVehNo() + " 车牌号征信级别为C级，不可使用！");
							return result;
						}
					}
				}
			} catch (Exception e) {
				BaseLogUtils.error(logger, "modifyGpsInfos", "校验车牌号c级Exception : " + e, CurrentThreadContext.getCurrentUserName());
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				return result;
			}

			try {
				 saveGPS(list, customManagerWorkNum, prjId);
			}catch (BaseException e) {
				BaseLogUtils.error(logger, "modifyGpsInfos", "组装GPS信息Exception : " + e, CurrentThreadContext.getCurrentUserName());
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(e.getMessage());
				return result;
			} catch (Exception e) {
				BaseLogUtils.newLogger("组装GPS信息Exception:").setThrowable(e).error(LogExceptionEnum.COMMON_CODE_0002);
				BaseLogUtils.error(logger, "modifyGpsInfos", "组装GPS信息Exception : " + e, CurrentThreadContext.getCurrentUserName());
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				return result;
			}
			try {
				for (PrjPrdDtlVO prjPrdDtlVO : list) {
					saveVehNo(prjPrdDtlVO, prjId);
				}
			} catch (Exception e) {
				BaseLogUtils.error(logger, "modifyGpsInfos", "维护车牌号信息Exception : " + e, CurrentThreadContext.getCurrentUserName());
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(e.getMessage());
				return result;
			}

			try {
				boolean success = this.prjPrdDtlService.modifyPrjPrdDtlList(list);
				if (!success) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
					BaseLogUtils.info(logger, "modifyGpsInfos", "修改失败.[prjPrdDtlInfoList=" + prjPrdDtlInfoList + "] DATA:" + JSON.toJSONString(prjPrdDtlInfoList), CurrentThreadContext.getCurrentUserName());
				}
				for (PrjPrdDtlVO prjPrdDtlVO : list) {
					BaseLogUtils.newLogger("产品明细实时发送设备信息开始入参dtlId=" + prjPrdDtlVO.getId()).info();
					boolean b = deviceInfoApiService.sendDeviceInfo(prjPrdDtlVO.getId());
					BaseLogUtils.newLogger("产品明细实时发送设备信息返回结果dtlId=" + prjPrdDtlVO.getId() + "b=" + b).info();
				}
				BaseLogUtils.info(logger, "modifyGpsInfos", "修改成功.[prjPrdDtlInfoList=" + prjPrdDtlInfoList + "] DATA:" + JSON.toJSONString(prjPrdDtlInfoList), CurrentThreadContext.getCurrentUserName());
			} catch (Exception ex) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.error(logger, "modifyGpsInfos", "修改失败Exception :" + ex, CurrentThreadContext.getCurrentUserName());
				BaseLogUtils.error(logger, "modifyGpsInfos", "修改失败.[prjPrdDtlInfoList=" + prjPrdDtlInfoList + "] DATA:" + JSON.toJSONString(prjPrdDtlInfoList) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			}
		}

		return result;
	}

	private void saveVehNo(PrjPrdDtlVO prjPrdDtlVO, String prjId) throws BaseException{
		// 保存车牌号
		BaseLogUtils.info(logger, "modifyGpsInfos", "项目id="+ prjId +"产品明细id：" + prjPrdDtlVO.getId(), CurrentThreadContext.getCurrentUserName());
		PrjPrdLicInfoVO licInfoVOObj = this.prjPrdLicInfoService.selectById(prjPrdDtlVO.getId());
		BaseLogUtils.info(logger, "modifyGpsInfos", "车牌号信息：" + JSON.toJSONString(licInfoVOObj) + ", 产品明细id:" + JSON.toJSONString(prjPrdDtlVO), CurrentThreadContext.getCurrentUserName());
		if (licInfoVOObj != null) {
			if (StringUtils.isNotBlank(licInfoVOObj.getVehNo())){
				if(!licInfoVOObj.getVehNo().equals(prjPrdDtlVO.getVehNo())){
					licInfoVOObj.setVerification("");// 如果修改的车牌号是没有验证的，要去掉验车标识
				}
			}
			licInfoVOObj.setVehNo(prjPrdDtlVO.getVehNo());
			licInfoVOObj.setMdfTm(new Date());
			licInfoVOObj.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			boolean modify = prjPrdLicInfoService.modify(licInfoVOObj);
			BaseLogUtils.newLogger("贷后服务调用-修改车牌号调用结束modify=" + modify,CurrentThreadContext.getCurrentUserName()).info();
			//保存或修改  调用验车方案的折扣比例更新可贷金额
			if (null != prjId && null != prjPrdDtlVO.getVehNo() && null != prjPrdDtlVO.getId()){
				this.prjPrdBscInfoService.getLoanableAmt(prjId, prjPrdDtlVO.getVehNo(), prjPrdDtlVO.getId());
			}
		} else {
			if (StringUtils.isNotBlank(prjPrdDtlVO.getVehNo())){
				PrjPrdLicInfoVO licInfoVO = new PrjPrdLicInfoVO();
				licInfoVO.setId(prjPrdDtlVO.getId());
				licInfoVO.setIsDel(0);
				licInfoVO.setVehNo(prjPrdDtlVO.getVehNo());
				licInfoVO.setAudStsCd("0");
				licInfoVO.setCrtTm(new Date());
				licInfoVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
				Long add = this.prjPrdLicInfoService.add(licInfoVO);
				BaseLogUtils.newLogger("贷后服务调用-增加车牌号调用结束add=" + add,CurrentThreadContext.getCurrentUserName()).info();
				//保存或修改  调用验车方案的折扣比例更新可贷金额
				if (null != prjId && null != prjPrdDtlVO.getVehNo() && null != prjPrdDtlVO.getId()){
					this.prjPrdBscInfoService.getLoanableAmt(prjId, prjPrdDtlVO.getVehNo(), prjPrdDtlVO.getId());
				}
			}

		}
	}

	private PrjPrdDtlGpsVO getGPSinfo(PrjPrdDtlGpsVO prjPrdDtlGpsVO){
		cmm.mid.core.framework.dto.DataResultDTO dto = this.prjPrdVehInfoService.getGPSInfo(prjPrdDtlGpsVO.getGpsCardNo());
		if (null != dto.getData()){
			JSONObject obj = (JSONObject) JSONObject.toJSON(dto.getData());
			prjPrdDtlGpsVO.setUseTypCd(obj.getString("useType"));// 领用状态 0.未领用 1.已领用
			prjPrdDtlGpsVO.setGpsStsCd(obj.getString("isExist"));// GPS平台状态 0.参数错误 1.设备不存在 2.设备正常 3.设备无位置信息,4：设备未入库
			prjPrdDtlGpsVO.setGpsAddrInfo(obj.getString("address"));// 中文位置信息
			prjPrdDtlGpsVO.setLat(obj.getString("lat"));// 纬度（保留两位小数）
			prjPrdDtlGpsVO.setLng(obj.getString("lng"));// 经度（保留两位小数）
			prjPrdDtlGpsVO.setOnlineType(obj.getString("onlineType"));
		}

		return prjPrdDtlGpsVO;
	}

	/**
	 * 保存GPS信息
	 * @param customManagerWorkNum  客户经理工号
	 * @param list 项目产品明细列表
	 */
	private void saveGPS(List<PrjPrdDtlVO> list,String customManagerWorkNum,String prjId) throws BaseException{
		List<PrjPrdDtlGpsVO> voList = new ArrayList<>();

		for(PrjPrdDtlVO prjPrdDtlVO : list) {
			// 组装GPS信息
			PrjPrdDtlGpsVO gpsVO1 = new PrjPrdDtlGpsVO();
			PrjPrdDtlGpsVO gpsVO2 = new PrjPrdDtlGpsVO();
			PrjPrdDtlGpsVO gpsVO3 = new PrjPrdDtlGpsVO();


			queryGpsDeviceInfoSaveGpsOtherInfo(prjId,customManagerWorkNum,prjPrdDtlVO,1,gpsVO1);
			List<PrjPrdDtlGpsVO> gpsVOList = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 1);
			if (gpsVOList != null && gpsVOList.size() > 0) {
				gpsVO1 = gpsVOList.get(0);
				gpsVO1.setAudStsCd("0");// GPS审核状态 0.未审核 1.审核中 2.已审核 3.审核不通过 4.驳回呈报人
				gpsVO1.setGpsCardNo((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo().trim() : "0"));
				gpsVO1.setCrtTm(new Date());
				gpsVO1.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			} else {
				addGPS(1, (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo().trim() : "0"), prjPrdDtlVO.getId(),gpsVO1);
			}


			queryGpsDeviceInfoSaveGpsOtherInfo(prjId,customManagerWorkNum,prjPrdDtlVO,2,gpsVO2);
			List<PrjPrdDtlGpsVO> gpsVOList2 = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 2);
			if (gpsVOList2 != null && gpsVOList2.size() > 0) {
				gpsVO2 = gpsVOList2.get(0);
				gpsVO2.setAudStsCd("0");// GPS审核状态 0.未审核 1.审核中 2.已审核 3.审核不通过 4.驳回呈报人
				gpsVO2.setGpsCardNo((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2().trim() : "0"));
				gpsVO2.setCrtTm(new Date());
				gpsVO2.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			} else {
				addGPS(2, (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2().trim() : "0"), prjPrdDtlVO.getId(),gpsVO2);
			}

			queryGpsDeviceInfoSaveGpsOtherInfo(prjId,customManagerWorkNum,prjPrdDtlVO,3,gpsVO3);
			List<PrjPrdDtlGpsVO> gpsVOList3 = prjPrdDtlGpsService.gpsIsExist(prjPrdDtlVO.getId(), 3);
			if (gpsVOList3 != null && gpsVOList3.size() > 0) {
				gpsVO3 = gpsVOList3.get(0);
				gpsVO3.setAudStsCd("0");// GPS审核状态 0.未审核 1.审核中 2.已审核 3.审核不通过 4.驳回呈报人
				gpsVO3.setGpsCardNo((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3().trim() : "0"));
				gpsVO3.setCrtTm(new Date());
				gpsVO3.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			} else {
				addGPS(3, (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3().trim() : "0"), prjPrdDtlVO.getId(),gpsVO3);
			}
			voList.add(gpsVO1);
			voList.add(gpsVO2);
			voList.add(gpsVO3);
		}
		BaseLogUtils.newLogger("项目id:{},保存gps信息:{}",prjId,JSON.toJSONString(voList)).info();
		this.prjPrdDtlGpsService.batchInsertWithDel(voList);
	}


	/**
	 *
	 * @param serialNo gps序号
	 * @param gpsNum gps卡号
	 * @param dtlId 产品明细id
	 * @return
	 */
	private void addGPS(Integer serialNo,String gpsNum, Long dtlId,PrjPrdDtlGpsVO gpsVO){
		gpsVO.setAudStsCd("0");// GPS审核状态 0.未审核 1.审核中 2.已审核 3.审核不通过 4.驳回呈报人
		gpsVO.setPrjDtlId(dtlId);
		gpsVO.setGpsCardNo(gpsNum);
		gpsVO.setCrtTm(new Date());
		gpsVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		gpsVO.setSerialNo(serialNo);
		gpsVO.setIsDel(0);
	}


	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String gpsCardNo = request.getParameter("gpsCardNo");
		String gpsCardNo2 = request.getParameter("gpsCardNo2");
		String lnkCompId = request.getParameter("lnkCompId");//挂靠公司ID
		String lnkCompNm = request.getParameter("lnkCompNm");//挂靠公司名称
		String moreGps = request.getParameter("moreGps");//更多gps字符串
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		PrjPrdDtlVO entity = null;
		try {
			entity = new PrjPrdDtlVO();
			entity.setId(Long.valueOf(id));
			//if(StringUtils.isNotBlank(gpsCardNo)){
				entity.setGpsCardNo(gpsCardNo);
			//}
			//if(StringUtils.isNotBlank(gpsCardNo2)){
				entity.setGpsCardNo2(gpsCardNo2);
			//}
			if(StringUtils.isNotBlank(lnkCompId)){
				entity.setLnkCompId(Long.valueOf(lnkCompId));
			}else{
				entity.setLnkCompId(null);
			}
			if(StringUtils.isNotBlank(lnkCompNm)){
				entity.setLnkCompNm(lnkCompNm);
			}else{
				entity.setLnkCompNm("");
				entity.setLnkCompId(null);
			}
			boolean success = true;
			if(StringUtils.isNotBlank(lnkCompNm)){
				 success = this.prjPrdDtlService.modify(entity);
			}else{
				success = this.prjPrdDtlService.modifyPrjPrdDtlLnkCompGps(entity);
			}
			PrjPrdDtlGpsQueryCondition condition = new PrjPrdDtlGpsQueryCondition();
			condition.setPrjDtlId(Long.valueOf(id));;
			List<PrjPrdDtlGpsVO> voList = this.prjPrdDtlGpsService.searchList(condition);
			if(CollectionUtils.isNotEmpty(voList)){
				this.prjPrdDtlGpsService.removeByPrjDtlId(Long.valueOf(id));
			}
			if(StringUtils.isNotBlank(moreGps)){
				String[] gpsCardNos = moreGps.split(",");
				List<PrjPrdDtlGpsVO> prjPrdDtlGpsList = new ArrayList<PrjPrdDtlGpsVO>(); 
				if(gpsCardNos!=null){
					for(int i=0;i<gpsCardNos.length;i++){
						PrjPrdDtlGpsVO vo =new PrjPrdDtlGpsVO();
						vo.setGpsCardNo(gpsCardNos[i]);
						vo.setPrjDtlId(Long.valueOf(id));
						vo.setIsDel(BaseConstant.IS_YESNO_NO);
						vo.setCrtTm(new Date());
						vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
						prjPrdDtlGpsList.add(vo);
					}
					this.prjPrdDtlGpsService.addPrjPrdDtlGpsList(prjPrdDtlGpsList);
				}
			}
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	
	/**
	 * 修改产品明细对应的卡车信息
	 * @param prdCd 产品用途：二级类型代码
	 */
	@RequestMapping(value = "/modifyPrdDtlPrdInfo.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyPrdDtlPrdInfo(HttpServletRequest request, HttpServletResponse response,Long styleId,String carLen , String prdLvlCd,@RequestParam(required = false,defaultValue = "0") String auth,
									  String prdCd ) throws BaseException {
		String dtlId = request.getParameter("dtlId");//产品明细ID
		String isAuditNode = request.getParameter("isAuditNode");//信审节点标志
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		BaseLogUtils.info(logger, "modifyPrdDtlPrdInfo", "信审节点标志.[isAuditNode="+isAuditNode+"] ,项目产品明细ID.[dtlId=" +dtlId + "]", CurrentThreadContext.getCurrentUserName());
		try {
			// 换车
			if(styleId != null){
				this.prjPrdDtlService.modifyPrd(Long.valueOf(dtlId),styleId,carLen,prdLvlCd,auth,prdCd);
			}
			// 信审审核节点,同步产品指导价
			BaseLogUtils.newLogger("modifyPrdDtlPrdInfo 校验,信审标志={},产品明细ID={}"
					,BaseConstant.IS_YESNO_YES_STR.equals(isAuditNode),StringUtils.isNotBlank(dtlId)).info();
			if (BaseConstant.IS_YESNO_YES_STR.equals(isAuditNode) && StringUtils.isNotBlank(dtlId)) {
				//获取产品明细信息
				PrjPrdDtlVO prjPrdDtlVO = prjPrdDtlService.selectById(Long.valueOf(dtlId));
				BaseLogUtils.info(logger, "modifyPrdDtlPrdInfo",
						"信审节点标志.[isAuditNode="+isAuditNode+"] ,项目产品明细ID.[dtlId=" +dtlId + "]" +
								", 项目产品明细信息prjPrdDtlVO:" + JSONObject.toJSONString(prjPrdDtlVO), CurrentThreadContext.getCurrentUserName());
				if (prjPrdDtlVO != null) {
					if (prjPrdDtlVO.getPrjPrdId() != null) {
						//获取产品信息
						PrjPrdBscInfoVO prjPrdBscInfoVO = prjPrdBscInfoService.selectById(prjPrdDtlVO.getPrjPrdId());
						BaseLogUtils.info(logger, "modifyPrdDtlPrdInfo",
								"信审节点标志.[isAuditNode="+isAuditNode+"] ,项目产品ID.[PrjPrdId=" +prjPrdDtlVO.getPrjPrdId() + "]" +
										", 项目产品信息prjPrdBscInfoVO:" + JSONObject.toJSONString(prjPrdBscInfoVO), CurrentThreadContext.getCurrentUserName());
						if (prjPrdBscInfoVO != null) {
							Long carStyleId = prjPrdBscInfoVO.getStyleId();//车系ID
							if (carStyleId != null) {
								//查询车型库信息
								VechileStyleDTO vechileStyleDTO = styleApiService.selectById(carStyleId);
								BaseLogUtils.info(logger, "modifyPrdDtlPrdInfo",
										"信审节点标志.[isAuditNode="+isAuditNode+"] ,项目产品明细ID.[dtlId=" +dtlId + "]" +
												", 车辆信息vechileStyleDTO:" + JSONObject.toJSONString(vechileStyleDTO), CurrentThreadContext.getCurrentUserName());
								if (vechileStyleDTO != null) {
									Double mfrGuderPc = vechileStyleDTO.getStyleMsrp();//厂商指导价
									if (mfrGuderPc != null) {
										prjPrdBscInfoVO.setMfrGuidePc(mfrGuderPc * 1000000); //万元转为分
										prjPrdBscInfoService.modify(prjPrdBscInfoVO);
									}
								}
							}
						}

					}
				}
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+dtlId+"] ", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+dtlId+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+dtlId+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 修改产品明细对应的乘用车信息
	 */
	@RequestMapping(value = "/modifyPrdDtlCarPrdInfo.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyPrdDtlCarPrdInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String dtlId = request.getParameter("dtlId");//项目产品明细ID
		String engMdl = request.getParameter("engMdl");//发动机型号
		String engNo = request.getParameter("engNo");//发动机号
		String prdMdl = request.getParameter("prdMdl");//产品型号
		String vin = request.getParameter("vin");//车架号
		String gpsCardNo = request.getParameter("gpsCardNo");//gps卡号1
		String gpsCardNo2 = request.getParameter("gpsCardNo2");//gps卡号1
		String gpsTypCd = request.getParameter("gpsTypCd");//gps类型
		String gpsTypCd2 = request.getParameter("gpsTypCd2");//gps类型2
		String gpsMfr = request.getParameter("gpsMfr");//厂商名称
		String gpsMfr2 = request.getParameter("gpsMfr2");//厂商名称2
		String moreGps = request.getParameter("moreGps");//更多gps字符串
		String gpsInstall = request.getParameter("gpsInstall");//gps是否安装
		String gpsInstallUsr = request.getParameter("gpsInstallUsr");//gps安装人
		String seatQtyCd = request.getParameter("seatQtyCd");//座位数
		String carLen = request.getParameter("carLen");//车身长度
		String lnkCompNm = request.getParameter("lnkCompNm");//挂靠公司
		String lnkCompId = request.getParameter("lnkCompId");//挂靠公司
		String prdId = request.getParameter("prdId");//产品明细ID
		String Caralter = request.getParameter("Caralter");//商助
		String vinValidRes = request.getParameter("vinValidRes");//商助
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(dtlId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyPrdDtlPrdInfo", "修改数据,产品明细数据不能为空.[id="+dtlId+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrjPrdDtlVO dtl = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));
			PrjPrdDtlQueryCondition prjPrdDtlQc = new PrjPrdDtlQueryCondition();
			prjPrdDtlQc.setPrjPrdId(dtl.getPrjPrdId());
			List<PrjPrdDtlVO> list = this.prjPrdDtlService.selectList(prjPrdDtlQc);
			if(CollectionUtils.isNotEmpty(list)){
				if(list.size()==1){
					PrjPrdBscInfoVO prjPrdBscInfo = this.prjPrdBscInfoService.selectById(dtl.getPrjPrdId());
					prjPrdBscInfo.setPrdMdl(prdMdl);
					this.prjPrdBscInfoService.modify(prjPrdBscInfo);
				}
			}
				dtl.setEngMdl(engMdl);
				dtl.setPrdMdl(prdMdl);
				dtl.setVin(vin);
				dtl.setVinValidRes(vinValidRes);
                if(!"1".equals(vinValidRes)){
                    throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,"错误，请修改ViN信息");
                }
				dtl.setVinValidRes(vinValidRes);
				dtl.setGpsCardNo(gpsCardNo);
				dtl.setGpsCardNo2(gpsCardNo2);
				dtl.setGpsTypCd(gpsTypCd);
				dtl.setGpsTypCd2(gpsTypCd2);
				dtl.setGpsMfr(gpsMfr);
				dtl.setGpsMfr2(gpsMfr2);
				dtl.setEngNo(engNo);
				dtl.setGpsInstall(gpsInstall);
				dtl.setGpsInstallUsr(gpsInstallUsr);
				if(StringUtils.isNotEmpty(lnkCompNm) ){
					dtl.setLnkCompNm(lnkCompNm);//挂靠公司
				} 
				if(StringUtils.isNotEmpty(lnkCompId) ){
					dtl.setLnkCompId(Long.valueOf(lnkCompId));//挂靠公司Id
				} 
				
				if(StringUtils.isNotBlank(Caralter)){
					if(StringUtils.isBlank(gpsCardNo)){
						 throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"GPS卡号1不能为空！");
					}

					if(StringUtils.isBlank(gpsTypCd)){
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"GPS类型1不能为空！");
					}

					if(StringUtils.isBlank(gpsMfr)){
						throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"GPS厂商1不能为空！");
					}
				}

				this.prjPrdDtlService.modify(dtl);
				PrjPrdDtlExtDTO prjPrdDtlExt = this.prjPrdDtlExtApiService.selectById(Long.valueOf(dtlId));
				if(null != prjPrdDtlExt){
					PrjPrdDtlExtDTO entity = new PrjPrdDtlExtDTO();
					entity.setId(prjPrdDtlExt.getId());
					entity.setSeatQtyCd(seatQtyCd);
					if(StringUtils.isNotBlank(carLen)){
						entity.setCarLen(Long.valueOf(carLen));
					}
					entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
					entity.setMdfTm(new Date());
					entity.setEngMdl(engMdl);
					this.prjPrdDtlExtApiService.modify(entity);
				}
				//修改客车座位数，车身长度,发动机型号
				PrjPrdDtlExtDTO entity = new PrjPrdDtlExtDTO();
				entity.setId(dtl.getPrjPrdId());
				entity.setSeatQtyCd(seatQtyCd);
				if(StringUtils.isNotBlank(carLen)){
                    entity.setCarLen(Long.valueOf(carLen));
                }
				entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
				entity.setMdfTm(new Date());
				entity.setEngMdl(engMdl);
				this.prjPrdDtlExtApiService.modify(entity);

			PrjPrdDtlGpsQueryCondition condition = new PrjPrdDtlGpsQueryCondition();
			condition.setPrjDtlId(Long.valueOf(dtlId));
			List<PrjPrdDtlGpsVO> voList = this.prjPrdDtlGpsService.searchList(condition);
			if(CollectionUtils.isNotEmpty(voList)){
				this.prjPrdDtlGpsService.removeByPrjDtlId(Long.valueOf(dtlId));
			}
			if(StringUtils.isNotBlank(moreGps)){
				String[] gpsCardNos = moreGps.split(",");
				List<PrjPrdDtlGpsVO> prjPrdDtlGpsList = new ArrayList<PrjPrdDtlGpsVO>(); 
				if(gpsCardNos!=null){
					for(int i=0;i<gpsCardNos.length;i++){
						PrjPrdDtlGpsVO vo =new PrjPrdDtlGpsVO();
						vo.setGpsCardNo(gpsCardNos[i]);
						vo.setPrjDtlId(Long.valueOf(dtlId));
						vo.setIsDel(BaseConstant.IS_YESNO_NO);
						vo.setCrtTm(new Date());
						vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
						prjPrdDtlGpsList.add(vo);
					}
					this.prjPrdDtlGpsService.addPrjPrdDtlGpsList(prjPrdDtlGpsList);
				}
			}
			
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+dtlId+"] ", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+dtlId+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+dtlId+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
 		return result;
	}

    /**
     * 校验挂靠公司可支持挂靠项目是否选择二手车业务
     */
    @RequestMapping(value = "/checkLnkIsChooseUsedCar.do", method = RequestMethod.POST)
    @ResponseBody
    public Object checkLnkIsChooseUsedCar(HttpServletRequest request) throws BaseException {
        String lnkCompId = request.getParameter("lnkCompId");
        String prjTypCd = request.getParameter("prjTypCd");
        return prjPrdDtlService.checkLnkIsChooseUsedCar(lnkCompId, prjTypCd);
    }
	
	/**
	 * 修改产品的挂靠公司信息
	 */
	@RequestMapping(value = "/modifyPrdLnkComp.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyPrdLnkComp(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String dtlId = request.getParameter("dtlId");//产品明细ID
		String prdDtlIds = request.getParameter("prdDtlIds");
		String lnkCmpId = request.getParameter("lnkCompId");//挂靠公司ID
		String lnkCmpNm = request.getParameter("lnkCmpNm");//挂靠公司名称
		String lnkCompMsg = request.getParameter("lnkCompMsg");//挂靠公司名称
		String lnkCompType = request.getParameter("lnkCompType");//挂靠公司名称
		String splId = request.getParameter("splId");//供应商id
		Long lnkStartLvl = StringUtils.isNotEmpty(request.getParameter("lnkStartLvl")) ? Long.valueOf(request.getParameter("lnkStartLvl")) : null;//挂靠公司星级
		String prjId = request.getParameter("prjId");
		String vehNo = request.getParameter("vehNo");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(lnkCmpId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,挂靠公司主键不存在.[id="+lnkCmpId+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		List<Long> idList = new ArrayList<Long>();
		if(prdDtlIds == null){
			JSONArray idsArray = JSONArray.fromObject(Long.valueOf(dtlId));
			for (Object object : idsArray) {
				idList.add(Long.valueOf(object.toString()));
			}
		}else if (dtlId == null){
			JSONArray idsArray = JSONArray.fromObject(prdDtlIds);
			for (Object object : idsArray) {
				idList.add(Long.valueOf(object.toString()));
			}
		}
		
		try {
			//查询挂靠公司敞口值是否可以使用该挂靠公司
			boolean flag = this.prjPrdDtlService.checkPrjLnkCompCrAmtValue(Long.valueOf(lnkCmpId));
			if(flag){
				if(StringUtils.isNotEmpty(prjId)){
					PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
					String prjTypCd = "";
					prjTypCd = prjBscInfoVO.getPrjTypCd();
					if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_ESCJYD.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_OWNJYD.equals(prjTypCd)){
						PrjPrdDtlQueryCondition qc = new PrjPrdDtlQueryCondition();
						qc.setPrjId(Long.valueOf(prjId));
						List<PrjPrdDtlVO> listAll = this.prjPrdDtlService.selectList(qc);
						List<Long> lnkIdList = new ArrayList<Long>();
						for (PrjPrdDtlVO prjPrdDtlVO : listAll) {
							lnkIdList.add(prjPrdDtlVO.getId());
						}
						PrjPrdDtlVO prjPrdDtlVO = listAll.get(listAll.size()-1);
						lnkIdList.remove(prjPrdDtlVO.getId());
						Long lnkCompIdFirst = prjPrdDtlVO.getLnkCompId();
						String lnkCompNmFirst = prjPrdDtlVO.getLnkCompNm();
						Long dtlIdFirst = prjPrdDtlVO.getId();
						if(StringUtils.isEmpty(dtlId)){
							dtlId = idList.get(0).toString();
						}
						if(!((Long.valueOf(dtlId)).equals(dtlIdFirst))){
							if(StringUtils.isNotEmpty(lnkCompIdFirst)){
								if(!(lnkCompIdFirst.equals(Long.valueOf(lnkCmpId)))){
									if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd)){
										result.setSuccess(0);
										result.setInfo("车辆【" + vehNo + "】狮桥分结果不满足立项条件；请检查当前车辆是否在【" + lnkCompNmFirst + "】下查询过狮桥分或狮桥分是否满足使用条件！");
									}else{
										result.setSuccess(0);
										result.setInfo("请检查当前车辆是否在【" + lnkCompNmFirst + "】下查询过狮桥分或狮桥分是否满足使用条件！");
									}
									return result;
								}
							}else{
								if(StringUtils.isNotEmpty(lnkCmpId)){
									result.setSuccess(BaseConstant.IS_YESNO_NO);
									result.setInfo("已定位为私户不能选择挂靠公司");
									return result;
								}
							}
						}else{
							if(!(Long.valueOf(lnkCmpId).equals(lnkCompIdFirst)) && CollectionUtils.isNotEmpty(lnkIdList)){
								this.prjPrdDtlService.removePrdDtlLnkCompByIds(lnkIdList);
							}
						}
						DataResultDTO resultDTO = this.prjLnkCompService.selectRiskLnkList(Long.valueOf(prjId), vehNo, null);
						if(resultDTO != null && resultDTO.getData() != null){
							List<RcCstChannelInfoDTO> rcCstChannelInfoDTOS = (List<RcCstChannelInfoDTO>)(resultDTO.getData());
							if(CollectionUtils.isNotEmpty(rcCstChannelInfoDTOS)){
								for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
									Long channelId = rcCstChannelInfoDTO.getChannelId();
									if(lnkCmpId != null && (Long.valueOf(lnkCmpId)).equals(channelId)){
										lnkStartLvl = rcCstChannelInfoDTO.getSplStarLevel();
									}
								}
							}
						}
						this.prjPrdDtlService.modifyPrdDtlLnkCompNew(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkStartLvl,lnkCompMsg,lnkCompType);
					}else if(PrjBscInfoConstant.CODE_BU_ORG_CD_ZK.equals(prjBscInfoVO.getBuOrgCd()) && (PrjBscInfoConstant.PRJ_TYP_CD_CPYW.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_CTYW.equals(prjTypCd))){
						//this.prjPrdDtlService.modifyPrdDtlLnkComp(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkCmpMsg,lnkCmpType);
						this.prjPrdDtlService.modifyPrdDtlLnkCompNew(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkStartLvl,lnkCompMsg,lnkCompType);
						//挂靠公司变更更新前置征信id
						//REQ-12980 如果选择了挂靠公司 取挂靠公司的征信id
						//默认根据供应商查询最低级别的前置征信id
						String rcCstBscInfoId = this.prjLnkCompService.getRrcCstBscInfoId(Long.valueOf(prjId),Long.valueOf(splId));
						String rlRcCstId = null;
						if(StringUtils.isNotBlank(lnkCmpId)){
							//查询绑定征信的挂靠公司数据
							DataResultDTO dataResultDTO = this.prjLnkCompService.selectRiskLnkList(Long.valueOf(prjId), null, splId == null ? null : Long.valueOf(splId));
							List<RcCstChannelInfoDTO> rcCstChannelInfoDTOS = new ArrayList<>();
							if(dataResultDTO != null && dataResultDTO.getData() != null) {
								rcCstChannelInfoDTOS = (List<RcCstChannelInfoDTO>) (dataResultDTO.getData());
							}
							for (RcCstChannelInfoDTO rcCstChannelInfoDTO : rcCstChannelInfoDTOS) {
								if(rcCstChannelInfoDTO.getChannelId().equals(Long.valueOf(lnkCmpId))){
									if(rcCstChannelInfoDTO.getRcCstBscInfoId() != null){
										rcCstBscInfoId = String.valueOf(rcCstChannelInfoDTO.getRcCstBscInfoId());
									}
								}
							}
						}
						/*if (StringUtils.isNotEmpty(prjBscInfoVO.getInsCode()) && prjBscInfoVO.getInsCode().equals(PrjBscInfoConstant.PRJ_INS_CODE_ICBC)){
							PrjCheckResultDTO checkResult = this.projectApiService.getPrjCheckResult(prjBscInfoVO.getCstId(), splId == null ? null : Long.valueOf(splId));
							if(StringUtils.isEmpty(checkResult.getResultCode())){

								Map<String, Object> objectMap = checkResult.getRcCstBscInfoMap();
								if (CollectionUtils.isMapEmpty(objectMap)){
									result.setSuccess(BaseConstant.IS_YESNO_NO);
									result.setInfo("未查询到配偶征信信息");
									return result;
								}
								List<RcCstBscInfoDTO> rcCstBscInfoDTOList = (List<RcCstBscInfoDTO>)objectMap.get("rlRcCstBscInfoList");
								if (CollectionUtils.isEmpty(rcCstBscInfoDTOList)){
									result.setSuccess(BaseConstant.IS_YESNO_NO);
									result.setInfo("未查询到配偶征信信息");
									return result;
								}

								for (RcCstBscInfoDTO rcCstBscInfoDTO : rcCstBscInfoDTOList){
									if(rcCstBscInfoDTO.getRskLvlCd().equals("3")){
										result.setSuccess(BaseConstant.IS_YESNO_NO);
										result.setInfo("配偶征信级别低不支持立项");
										return result;
									}
									rlRcCstId = String.valueOf(rcCstBscInfoDTO.getId());
								}
							}
						}*/
						if(StringUtils.isNotBlank(rcCstBscInfoId)){
							BaseLogUtils.info(logger,"addPrdAndPrdDetail","修改征信开始..." + rcCstBscInfoId + prjId);
							boolean b = this.projectApiService.modifyPrjBscRcCstInfo(prjId, rcCstBscInfoId, "1", rlRcCstId);
							BaseLogUtils.info(logger,"addPrdAndPrdDetail","修改征信结束..." + b);
						}
					}else{
						this.prjPrdDtlService.modifyPrdDtlLnkCompNew(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkStartLvl,lnkCompMsg,lnkCompType);
					}
				}else{
					//this.prjPrdDtlService.modifyPrdDtlLnkComp(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkCmpMsg,lnkCmpType);
					this.prjPrdDtlService.modifyPrdDtlLnkCompNew(idList,Long.valueOf(lnkCmpId),lnkCmpNm,lnkStartLvl,lnkCompMsg,lnkCompType);
				}
				//返回前端挂靠公司名称
				result.setData(lnkCmpNm);
			}else{
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("敞口受限！不允许使用该挂靠公司！");
			}
			if(prdDtlIds == "") {
			BaseLogUtils.info(logger, "modify", "修改成功.[dtlId="+dtlId+"] ", CurrentThreadContext.getCurrentUserName());
			
			} 
			BaseLogUtils.info(logger, "modify", "修改成功.[ids="+prdDtlIds+"] ", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			if(prdDtlIds == "") {
			BaseLogUtils.info(logger, "modify", "修改失败.[dtlId="+dtlId+"] "+ ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			} 
			BaseLogUtils.info(logger, "modify", "修改失败.[ids="+prdDtlIds+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			if(prdDtlIds == "") {
			BaseLogUtils.info(logger, "modify", "修改失败.[dtlId="+dtlId+"] " + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			} 
			BaseLogUtils.error(logger, "modify", "修改失败.[ids="+prdDtlIds+"] "  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 移除产品的挂靠公司
	 */
	@RequestMapping(value = "/removePrdDtlLnkCompByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removePrdDtlLnkCompByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		List<Long> idList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idList.add(Long.valueOf(object.toString()));
		}
		try {
			PrjPrdDtlVO prjPrdDtlVO = this.prjPrdDtlService.selectById(idList.get(0));
			Long prjId = prjPrdDtlVO.getPrjId();
			PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(prjId);
			String prjTypCd = "";
			if (prjBscInfoVO != null) {
				prjTypCd = prjBscInfoVO.getPrjTypCd();
			}
			if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYWUL.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_ESCJYD.equals(prjTypCd) || PrjBscInfoConstant.PRJ_TYP_CD_OWNJYD.equals(prjTypCd)){
				PrjPrdDtlQueryCondition qc = new PrjPrdDtlQueryCondition();
				qc.setPrjId(Long.valueOf(prjId));
				List<PrjPrdDtlVO> listAll = this.prjPrdDtlService.selectList(qc);
				List<Long> lnkIdList = new ArrayList<Long>();
				for (PrjPrdDtlVO prjPrdDtl : listAll) {
					lnkIdList.add(prjPrdDtl.getId());
				}
				Long id = listAll.get(listAll.size() - 1).getId();
				if(idList.contains(id)){
					this.prjPrdDtlService.removePrdDtlLnkCompByIds(lnkIdList);
				}else{
					this.prjPrdDtlService.removePrdDtlLnkCompByIds(idList);
				}
			}else{
				this.prjPrdDtlService.removePrdDtlLnkCompByIds(idList);
			}
			BaseLogUtils.info(logger, "removeById", "删除数据.[id="+idList+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除数据失败.[id="+idList+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除数据失败.[id="+idList+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			ex.printStackTrace();
		}

		return result;
	}
	
	/**
	 * 根据ID查询产品型号信息
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getPrjPrdDtlPrdInfoById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getPrjPrdDtlPrdInfoById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrjPrdDtlExtDTO dto = this.prjPrdDtlExtApiService.selectById(Long.valueOf(id));
			if(null == dto){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(dto);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 关联查询支付表的信息
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initPayList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initPayList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String prjId = request.getParameter("prjId");
		String prjPrdId = request.getParameter("prjPrdId");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		PrjPrdDtlQueryCondition qc = new PrjPrdDtlQueryCondition();
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		page.setCondition(qc);

		Pager pager = this.prjPrdDtlService.searchPrjPayListPage(page);
		List<PrjPrdDtlVO> list = (List<PrjPrdDtlVO>) pager.getResultList();
		ListPageVO<PrjPrdDtlVO> listPage = new ListPageVO<PrjPrdDtlVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 修改
	 */
	@RequestMapping(value = "/modifyPrjPrdDtl.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyPrjPrdDtl(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String paySchId = request.getParameter("paySchId");
		String prdStsCd = request.getParameter("prdStsCd");
		String stlDt = request.getParameter("stlDt");
		String backDt = request.getParameter("backDt");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		PrjPrdDtlVO entity = null;
		try {
			entity = new PrjPrdDtlVO();
			entity.setId(Long.valueOf(id));
			entity.setPaySchId(Long.valueOf(paySchId));
			if (StringUtils.isNotBlank(prdStsCd)) {
				entity.setPrdStsCd(prdStsCd);
			}
			if (StringUtils.isNotBlank(stlDt)) {
				entity.setStlDt(DateUtils.formatStringToDate(stlDt, DateUtils.YYYY_MM_DD));
			}
			if (StringUtils.isNotBlank(backDt)) {
				entity.setBackDt(DateUtils.formatStringToDate(backDt, DateUtils.YYYY_MM_DD));
			}
			boolean success = this.prjPrdDtlService.modifyDtlForOpt(entity);
			if (!success) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.info(logger, "modify", "修改失败.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	@RequestMapping("/addPrjPrdDtlExt.do")
	@ResponseBody
	public String addPrjPrdDtlExt(Long dtlId){
		projectApiService.addPrjPrdDtlPrdInfoByDtlId(dtlId,"11000","0000",0l);
		return "1";
	}


	/**
	 * 验证VIN码是否正确
	 */
	@RequestMapping("/validVin.do")
	@ResponseBody
	public DataResultVO validVin(String vin,String prdTypCd){
		DataResultVO res = new DataResultVO();
		res.setSuccess(2);
		res.setInfo("错误");
		if(StringUtils.isNotBlank(prdTypCd) && prdTypCd.equals("022")){ // 上装不校验 直接过
            res.setSuccess(1);
            res.setInfo("正确");
            return res;
        }

		if(StringUtils.isNotBlank(vin)){
			boolean checkRes = vinUtilsApiService.validVinCheckBit(vin.trim());
			BaseLogUtils.info(logger,"validVin","校验VIN:{" + vin + "} ,校验结果为:{" +checkRes+ "}");
			if(checkRes){
				res.setSuccess(1);
				res.setInfo("正确");
			}
		}
		return res;
	}

	/**
	 * /project/prjprddtl/modifyVehNo.do
	 * 校验车牌号：项目类型：车抵贷业务线下
	 * 1、必须有一台车的车牌号是征信结果有效的车牌号
	 * 2、所有车辆设备必须增加车牌号
	 * @return
	 */
	@RequestMapping(value = "/modifyVehNo.do", method = {RequestMethod.GET})
	@ResponseBody
	public DataResultVO modifyVehNo(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");// 项目id

		DataResultVO result = new DataResultVO();
		result.setSuccess(BaseConstant.IS_YESNO_YES);


		PrjPrdDtlQueryCondition dtlQueryCondition = new PrjPrdDtlQueryCondition();
		dtlQueryCondition.setPrjId(Long.valueOf(prjId));
		List<PrjPrdDtlVO> dtlVOList = this.prjPrdDtlService.selectList(dtlQueryCondition);

		try {
			if (CollectionUtils.isNotEmpty(dtlVOList)) {
				for (PrjPrdDtlVO dtlVO : dtlVOList) {
					PrjPrdLicInfoVO licInfoVO = this.prjPrdLicInfoService.selectById(Long.valueOf(dtlVO.getId()));
					if (null == licInfoVO || StringUtils.isBlank(licInfoVO.getVehNo())) {
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("含有未添加车牌号的车辆设备，请去车辆设备中添加车牌号！");
						return result;
					}
				}
			}
			BaseLogUtils.info(logger, "modifyVehNo", "校验车牌号 ,prjId为:{" + prjId + "}");
		} catch (Exception e) {
			BaseLogUtils.info(logger, "modifyVehNo", "校验没添加的车牌号 ,异常信息: " + e);
		}


		try {
			//  校验征信结果
			List<PrjPrdLicInfoVO> licInfoVOList = new ArrayList<>();
			if (CollectionUtils.isNotEmpty(dtlVOList)) {
				for (PrjPrdDtlVO dtlVO : dtlVOList) {
					PrjPrdLicInfoVO licInfoVO = this.prjPrdLicInfoService.selectById(Long.valueOf(dtlVO.getId()));
					licInfoVOList.add(licInfoVO);
				}
			}

			Integer flag = this.projectApiService.vefifyVehNoRisk(PrjPrdLicInfoVOTransform.toDTOList(licInfoVOList),
					Long.valueOf(prjId), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CurrentThreadContext.getCurrentBuOrgCd());
			if (null != flag && flag == 0) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("发现有车牌号未查征信或征信不合规，确认征信信息！");
				return result;
			}

			BaseLogUtils.info(logger, "modifyVehNo", "校验车牌号 ,flag:{" + flag + "}");
		} catch (Exception e) {
			BaseLogUtils.info(logger, "modifyVehNo", "校验车牌号 ,异常信息: " + e);
		}
		return result;
	}

	/**
	 * http://10.20.6.20:10000/project/prjprddtl/getVehNo.do?prjId=190314077007262
	 * 测试接口，仅为查询有效征信的车牌号，无实际业务调用
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "/getVehNo.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object getVehNo(HttpServletRequest request, HttpServletResponse response){
		String prjId = request.getParameter("prjId");// 项目id
		List<String> vehNoList = this.projectApiService.getVehNoByCredit(Long.valueOf(prjId),CurrentThreadContext.getCurrentSysCd(),
				CurrentThreadContext.getCurrentOrgCd(), CurrentThreadContext.getCurrentBuOrgCd());

		DataResultVO result = new DataResultVO();
		result.setSuccess(BaseConstant.IS_YESNO_YES);
		result.setData(vehNoList);

		return result;
	}


	/**
	 * 到渠道经理备案挂靠公司列表页面
	 */
	@RequestMapping(value = "/toPrjPrdDtlInfo.do", method = { RequestMethod.GET})
	public ModelAndView toPrjPrdDtlInfo(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");
		ModelAndView view = new ModelAndView("project/prjprddtl/prjPrdDtlInfo");
		BaseLogUtils.info(logger, "toPrjPrdDtlInfo", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		view.addObject("prjId", prjId);
		return view;
	}


	/**
	 * 根据挂靠公司id查询产品信息
	 *
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getByLnkCompId.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getByLnkCompId(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String lnkCompId = request.getParameter("lnkCompId");
        PrjPrdDtlQueryCondition dtlQueryCondition = new PrjPrdDtlQueryCondition();
        dtlQueryCondition.setLnkCompId(Long.valueOf(lnkCompId));
        List<PrjPrdDtlVO> dtlVOList = this.prjPrdDtlService.selectList(dtlQueryCondition);

        DataResultVO result = new DataResultVO();
        result.setSuccess(BaseConstant.IS_YESNO_YES);
        result.setData(dtlVOList);
		return result;
	}

	/**
	 * @Author liumengmeng
	 * @Description 批量处理--发动机号问题：合格证表与详情表不一致
	 * @Date 16:10 2019/12/19
	 * @Param []
	 * @return cmm.mid.core.framework.page.DataResultVO
	 **/
	@RequestMapping(value = "/batchInsertEngNo.do", method = { RequestMethod.POST })
	@ResponseBody
	public DataResultVO batchInsertEngNo(){
		int i = projectApiService.setEngNo();
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,
				SysLogConstant.LOG_CMM_UPDATE_SUCC);
		result.setData(i);
		return result;
	}

	/**
	 * 初始化外派业务管理二级列表
	 */
	@RequestMapping(value = "/selectExpBusTwoList.do", method = {RequestMethod.GET, RequestMethod.POST})
	@ResponseBody
	public Object selectExpBusTwoList(HttpServletRequest request, HttpServletResponse response) {
		String lsCntNo = request.getParameter("lsCntNo");
		String stDt = request.getParameter("stDt");
		String endDt = request.getParameter("endDt");
		String cstMgrNm = request.getParameter("cstMgrNm");// 创建人（客户经理）
		String cstNm = request.getParameter("cstNm");
		String hidRisk = request.getParameter("hidRisk");//风险隐患
		String prjId = request.getParameter("prjId");

		if(StringUtils.isEmpty(prjId)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "项目ID不能为空.");
		}
		PrjPrdDtlQueryCondition qc = new PrjPrdDtlQueryCondition();
		if (StringUtils.isNotBlank(lsCntNo)) {
			qc.setLsCntNo(lsCntNo);
		}
		if(StringUtils.isNotBlank(stDt)){
			qc.setStDt(DateUtils.formatStringToDate(stDt, DateUtils.YYYY_MM_DD));
		}
		if(StringUtils.isNotBlank(endDt)){
			qc.setEndDt(DateUtils.formatStringToDate(endDt, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotBlank(cstMgrNm)) {
			qc.setCstMgrNm(cstMgrNm);
		}
		if (StringUtils.isNotBlank(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotBlank(hidRisk)) {
			qc.setHidRisk(hidRisk);
		}
		if(StringUtils.isNotBlank(prjId)){
			qc.setPrjId(Long.valueOf(prjId));
		}
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		List<PrjPrdDtlVO> list = this.prjPrdDtlService.selectExpBusTwoList(qc);
		BaseLogUtils.newWebLogger("===查询外派业务管理二级列表数据完成===list:" + JSON.toJSONString(list)).info();
		if(CollectionUtils.isNotEmpty(list)){
			return new ListPageVO<PrjPrdDtlVO>(list,list.size());
		}
		return null;
	}

	/**
	 * 轻卡审核挂靠公司-lnkCompLcvStatus
	 */
	@RequestMapping(value = "/checkLcvStatus.do", method = {RequestMethod.GET, RequestMethod.POST})
	@ResponseBody
	public Object checkLcvStatus(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		String pejPrdDtlId = request.getParameter("pejPrdDtlId");
		// String prjId = request.getParameter("prjId");
		PrjPrdDtlQueryCondition dtlQC = new PrjPrdDtlQueryCondition();
		if (StringUtils.isNotEmpty(pejPrdDtlId)) {
			List<Long> idList = new ArrayList<>();
			idList.add(Long.parseLong(pejPrdDtlId));
			dtlQC.setIdList(idList);
			List<PrjPrdDtlVO> list = this.prjPrdDtlService.selectList(dtlQC);
			if(CollectionUtils.isNotEmpty(list)){
				PrjPrdDtlVO prjPrdDtlVO = list.get(0);
				prjPrdDtlVO.setLnkCompLcvStatus("1");  // 当产品轻卡参数不为空并且是0的时候，证明需要校验未校验状态！（只限轻卡）
				// prjPrdDtlService.modifyLnkByLcv(dto);
				BaseLogUtils.newWebLogger("===轻卡审核挂靠公司-lnkCompLcvStatus===prjPrdDtlVO:" + JSON.toJSONString(prjPrdDtlVO)).info();
				boolean modify = this.prjPrdDtlService.modifyLnkByLcv(prjPrdDtlVO);
				BaseLogUtils.newWebLogger("===轻卡审核挂靠公司-lnkCompLcvStatus===modify:" + JSON.toJSONString(modify)).info();
				if(modify){
					result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
				}
			}
		}
		BaseLogUtils.newWebLogger("===轻卡审核挂靠公司-lnkCompLcvStatus完成===result:" + JSON.toJSONString(result)).info();
		return result;
	}

	/**
	 * @description 校验gps卡号是否使用
	 * @param gpsCardNo
	 * @param dtlId
	 * @return
	 */
	@RequestMapping(value = "/checkGpsIsUsed.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object checkGpsIsUsed(@RequestParam("gpsCardNo") String gpsCardNo,@RequestParam("dtlId") Long dtlId) {
		BaseLogUtils.newLogger("产品明细id:{},调用检查gps设备是否使用,gpsCardNo:{}",dtlId,gpsCardNo).info();
		ResponseData used = prjPrdDtlGpsApiService.isUsed(gpsCardNo, dtlId);
		BaseLogUtils.newLogger("产品明细id:{},调用检查gps设备是否使用,gpsCardNo:{},该设备是否已使用:{}",dtlId,gpsCardNo, null == used ? "错误" : JSON.toJSONString(used)).info();
		return used;
	}


	/**
	 * @description 查询客户经理工号
	 * @param prjId 项目id
	 */
	private String selectCustomManagerWorkNum(String prjId) {
		PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
		List<Long> list = new ArrayList<>();

		if (null != prjBscInfoVO) {
			// 客户经理id
			Long cstMgrId = prjBscInfoVO.getCstMgrId();
			list.add(cstMgrId);

			SysUsrQueryCondition sysUsrQueryCondition = new SysUsrQueryCondition();
			// 客户经理id
			sysUsrQueryCondition.setUsrIds(list);
			sysUsrQueryCondition.setSysCd("11000");

			List<SysUsrDTO> sysUsrDtoS = sysUsrApiService.searchSysUsrList(sysUsrQueryCondition);
			BaseLogUtils.newLogger("项目id:{},查询出来的系统用户:{}",prjId,JSON.toJSONString(sysUsrDtoS)).info();

			if (CollectionUtils.isNotEmpty(sysUsrDtoS)) {
				for (SysUsrDTO sysUsrDto : sysUsrDtoS) {
					  if (null != sysUsrDto && null != sysUsrDto.getUsrNm()) {
					  	  return  sysUsrDto.getUsrNm();
					  }
				}
			}
		}
		return null;
	}




	/**
	 * @description 查询GPS设备信息,调用大数据返回的数据
	 * @param prjId 项目id
	 * @param customManagerWorkNum 客户经理工号
	 * @param prjPrdDtlVO 产品信息详细
	 */
	private void queryGpsDeviceInfoOfHadoop(String prjId, String customManagerWorkNum, PrjPrdDtlVO prjPrdDtlVO, Integer serialNo,List<String> hintMsgList) {

		ResponseData responseData = null;
		if (serialNo.intValue() == 1) {
			 responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo().trim() : "0"), customManagerWorkNum);
		} else if (serialNo.intValue() == 2) {
			 responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2().trim() : "0"), customManagerWorkNum);
		} else {
			 responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3().trim() : "0"), customManagerWorkNum);
		}

		BaseLogUtils.newLogger("项目id:{},GPS序号:{},调用大数据平台返回的数据:{}",prjId,serialNo,null == responseData ? "错误" :JSON.toJSONString(responseData)).info();


		if (serialNo.intValue() == 1) {
			hadoopReturnInfo(responseData,(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo().trim() : "0"), customManagerWorkNum,prjId,hintMsgList);
		} else if (serialNo.intValue() == 2) {
			hadoopReturnInfo(responseData,(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2().trim() : "0"),customManagerWorkNum,prjId,hintMsgList);
		} else {
			hadoopReturnInfo(responseData,(StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3().trim() : "0"),customManagerWorkNum,prjId,hintMsgList);
		}
	}

	/**
	 * @description 查询大数据gps设备信息，保存gps其他信息
	 * @param prjId 项目id
	 * @param customManagerWorkNum 客户经理工号
	 * @param prjPrdDtlVO 产品明细信息
	 * @param serialNo gps序号
	 * @param prjPrdDtlGpsVO gpsVo
	 */
	private void  queryGpsDeviceInfoSaveGpsOtherInfo(String prjId, String customManagerWorkNum, PrjPrdDtlVO prjPrdDtlVO, Integer serialNo,PrjPrdDtlGpsVO prjPrdDtlGpsVO) {
		ResponseData responseData = null;
		if (serialNo.intValue() == 1) {
			responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) ? prjPrdDtlVO.getGpsCardNo().trim() : "0"), customManagerWorkNum);
		} else if (serialNo.intValue() == 2) {
			responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) ? prjPrdDtlVO.getGpsCardNo2().trim() : "0"), customManagerWorkNum);
		} else {
			responseData = prjPrdDtlGpsApiService.validateGpsDeviceOfHadoop((StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) ? prjPrdDtlVO.getGpsCardNo3().trim() : "0"), customManagerWorkNum);
		}

		BaseLogUtils.newLogger("项目id:{},GPS序号:{},调用大数据平台返回的数据:{}",prjId,serialNo,null == responseData ? "错误" :JSON.toJSONString(responseData)).info();

		if (null != responseData && null != responseData.getData()) {
			prjPrdDtlGpsVO.setReceiveRealName(((GpsDeviceDTO)responseData.getData()).getReceiveRealName());
			prjPrdDtlGpsVO.setReceiveName(((GpsDeviceDTO)responseData.getData()).getReceiveName());
			prjPrdDtlGpsVO.setGpsDeviceType(((GpsDeviceDTO)responseData.getData()).getGpsDeviceType());
		}

		BaseLogUtils.newLogger("项目id:{},GPS序号:{},保存的数据:{}",prjId,serialNo,JSON.toJSONString(prjPrdDtlGpsVO)).info();
	}


	/**
	 * 纯数字校验
	 * @param str
	 * @return
	 */
	private  boolean isNum(String str){
		Pattern pattern = Pattern.compile("^-?[0-9]+");
		if(pattern.matcher(str).matches()){
			//数字
			return true;
		} else {
			//非数字
			return false;
		}
	}

	/**
	 * @description  校验前端传过来的gps卡号
	 * @param gpsCardNo gps卡号
	 * @param errorMsgList 错误信息集合
	 */
	public void validateGpsCardNo(String gpsCardNo,List<String> errorMsgList) {
		if (StringUtils.isNotBlank(gpsCardNo) && !Objects.equals("0", gpsCardNo)) {
			if (!isNum(gpsCardNo)) {
				// 非数字
				errorMsgList.add(gpsCardNo + ",不是纯数字,请调整!");
			} else {
				// 数字的长度
				if (gpsCardNo.length() != 15) {
					errorMsgList.add(gpsCardNo + ",数字长度不等于15,请调整!");
				}
			}
		}
	}


	/**
	 * @description gps设备是否使用
	 * @param prjId 项目id
	 * @param prjPrdDtlVO 产品明细
	 * @param serialNo gps序号
	 * @return 0:占用 1:未占用 2:数据错误
	 */
	private String gpsDeviceIsUsed(String prjId,PrjPrdDtlVO prjPrdDtlVO, Integer serialNo) {
		ResponseData isUsedObj = null;
		if (serialNo.intValue() == 1) {
              if (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo()) && !Objects.equals("0",prjPrdDtlVO.getGpsCardNo())) {
				  isUsedObj = prjPrdDtlGpsApiService.isUsed(prjPrdDtlVO.getGpsCardNo(), prjPrdDtlVO.getId());
			  }
		} else if (serialNo.intValue() == 2) {
			if (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo2()) && !Objects.equals("0", prjPrdDtlVO.getGpsCardNo2())) {
				isUsedObj = prjPrdDtlGpsApiService.isUsed(prjPrdDtlVO.getGpsCardNo2(), prjPrdDtlVO.getId());
			}
		} else {
			 if (StringUtils.isNotBlank(prjPrdDtlVO.getGpsCardNo3()) && !Objects.equals("0", prjPrdDtlVO.getGpsCardNo3())) {
				 isUsedObj = prjPrdDtlGpsApiService.isUsed(prjPrdDtlVO.getGpsCardNo3(), prjPrdDtlVO.getId());
			 }
		}
		BaseLogUtils.newLogger("项目id:{},产品明细id:{},gps序号:{},是否使用:{}",prjId,prjPrdDtlVO.getId(),serialNo,null != isUsedObj ? JSON.toJSONString(isUsedObj) : "错误").info();

		return  null != isUsedObj && isUsedObj.isSuccess()? (String) isUsedObj.getData() : "";
	}

	/**
	 * @description 大数据返回的信息
	 * @param responseData 大数据返回的信息
	 * @param gpsCardNo gps卡号
	 * @param customManagerWorkNum 客户经理工号
	 * @param prjId 项目id
	 */
	private void hadoopReturnInfo(ResponseData responseData,String gpsCardNo,String customManagerWorkNum,String prjId,List<String> hintMsgList) {

		if (null != responseData) {
			if (!responseData.isSuccess()) {
				if ("hy4013".equals(responseData.getCode())) {
					// 报单人事业部下未查询到该设备
					throw new BaseException(gpsCardNo + "未查询到GPS设备，请核查!");

				} else if ("hy425".equals(responseData.getCode())) {
					//报单人账号在 GPS 系统暂无组织架构
					throw new BaseException(gpsCardNo + "GPS平台未查到当前客户经理信息，请核查!");

				} else {
					// 其他错误
					throw new BaseException(gpsCardNo + responseData.getMessage());
				}
			} else {

				PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
				if (null == prjBscInfoVO) {
					throw new BaseException("项目id:" + prjId +",gps卡号:"+ gpsCardNo + ",未找到项目基本信息!");
				}

				// 客户经理名称
				String cstMgrNm = prjBscInfoVO.getCstMgrNm();
				BaseLogUtils.newLogger("项目id:{},查询出来的客户经理名称:{}",prjBscInfoVO.getId(),StringUtils.isNotBlank(cstMgrNm) ? cstMgrNm :"无").info();

				GpsDeviceDTO gpsDeviceDTO = (GpsDeviceDTO) responseData.getData();
				String workNum = gpsDeviceDTO.getReceiveName();
				BaseLogUtils.newLogger("项目id:{},调用大数据返回的GPS设备领用人工号:{}",prjId,StringUtils.isNotBlank(workNum) ? workNum :"无").info();

				String receiveRealName = gpsDeviceDTO.getReceiveRealName();
				BaseLogUtils.newLogger("项目id:{},调用大数据返回GPS设备领用人姓名:{}",prjId,StringUtils.isNotBlank(receiveRealName) ? receiveRealName :"无").info();

				if (StringUtils.isNotBlank(receiveRealName)) {
					if (!Objects.equals(workNum,customManagerWorkNum)) {
						hintMsgList.add(gpsCardNo + ",GPS设备领用人【"+ receiveRealName +"】与实际使用人【"+ cstMgrNm +"】不一致，是否继续安装？");
					}
				}

			}

		} else {
			throw new BaseException("项目id:" + prjId +",gps卡号:"+ gpsCardNo + "，调用大数据返回空");
		}
	}

}

